Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matthew Vines 11 posts 31 karma points
    Aug 22, 2010 @ 03:03
    Matthew Vines
    0

    How to add an image wrapped in a link to the image so that end users may select the image.

    This I'm sure is fairly straight forward, but I have not created such an extension in Umbraco before, and I'm finding myself a little lost on how to begin.

    I would like a small snippet of html that I can insert into my templates with a targetable name that looks like the following.

    <a rel="galleryName" href="imagepath">

        <img href="imagepath" alt="alttext" />

    </a>

    To add content to this section the user will select a media item of type image, and fill out the galleryName, and alt text attributes.

    This seemed pretty straight forward, until I actually got started.  Is this a Macro, or a Data Type?  Is this done with XSLT or a User Control in C#?  I'm really just looking to have my hand held through this one so I can better understand the Umbraco way of doing things.

    Thanks for your time,

     

  • Hendrik Jan 71 posts 137 karma points
    Aug 22, 2010 @ 12:39
    Hendrik Jan
    0

    This can easily be done with a macro. And then you can choose between XSLT, 
    Phyton or a .NET user control. I suggest using with XSLT.
    Then give your macro parameters for the image, alt and gallery

     

     

  • Matthew Vines 11 posts 31 karma points
    Aug 22, 2010 @ 20:29
    Matthew Vines
    0

    Thanks for the start.  I'll let you know how it goes.

  • Matthew Vines 11 posts 31 karma points
    Aug 22, 2010 @ 22:41
    Matthew Vines
    0

    So I have this so far,

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library"
        exclude-result-prefixes="msxml umbraco.library">

      <xsl:output method="xml" omit-xml-declaration="yes"/>

      <xsl:param name="currentPage"/>
      <xsl:param name="galleryName" />
     
      <xsl:template match="/">
        <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/imageAlias, 0)" />
        <a ref="{$galleryName}" href="{$media/umbracoFile}">
          <img src="{$media/umbracoFile}" alt="{$media/altText}" />
        </a>
      </xsl:template>
    </xsl:stylesheet>

    I don't understand how to make the macro targetable in my document types.  So that I can say that macro 1 on the page uses this image, and macro 2 that one, etc.

    I will have 10 of these on a page, that will comprise a gallery for my user.  Then from his content tab, he can select 10 different images and add in the supporting alt text.  How do I differentiate 2 macros in my template?  Right now they are added with

    <umbraco:Macro gallery="galleryName" Alias="LinkAndImage" runat="server">umbraco:Macro>

    In my document type I had planned to assigne a field to each and place them on a tab for the gallery, but that doesn't appear to be the way this will work.

    Any help is appreciated, thanks once again for your time.

Please Sign in or register to post replies

Write your reply to:

Draft