Copied to clipboard

Flag this post as spam?

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


  • AN 22 posts 42 karma points
    May 11, 2010 @ 08:49
    AN
    0

    Problem placing umbraco:item within anchor title attribute in template

    Hi,

    In a template, I have an anchor tag eg. <a href="/" title="">Name</a>.

    When trying to place an umbraco:item within the title attribute, it's as if the templating engine does not catch the umbraco:item.

    I'm guessing it's something todo with placing umbraco:item's in enclosed <>..

    <a href="/" title="<umbraco:Item field="title" recursive="true" runat="server"></umbraco:Item>"><umbraco:Item field="title" recursive="true" runat="server"></umbraco:Item></a>

    Which in turn outputs

    <a href="/" title="&quot;&lt;umbraco:Item" field="title" recursive="true"></umbraco:Item>">Entered value</a>

     

    Help? :o)

  • Tobias Neugebauer 52 posts 93 karma points
    May 11, 2010 @ 10:13
    Tobias Neugebauer
    0

    Hello Andreas,

    I've tried your code with a smal change: i used single quotes instead of double quotes for the title attribute. This code worked for me:

    <a href="/" title='<umbraco:Item field="title" recursive="true"
    runat="server"></umbraco:Item>'><umbraco:Item
    field="title" recursive="true"
    runat="server"></umbraco:Item></a>

    I hope this does work for you also

    Toby

  • AN 22 posts 42 karma points
    May 18, 2010 @ 13:50
    AN
    0

    Hi Toby,

     

    Thanks, I've changed the code.

     

    However, I'd still like to know what was/is causing the problem..

     

    :o)

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 18, 2010 @ 14:05
    Jan Skovgaard
    0

    Hi Andreas

    I think the answer is implicitly in the post with the solution. It's probably because you used double quotes instead of single quotes, which has probably killed the parsing of the code since you are using double quotes in your HTML maybe.

    /Jan

  • AN 22 posts 42 karma points
    May 18, 2010 @ 14:52
    AN
    0

    Alright.. Would that be considered a bug, the Umbraco crew should be notified of, or is it ligitimate enough, that the parsing breaks when using double quotes in my situation?

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    May 18, 2010 @ 17:06
    Douglas Robar
    2

    It isn't a bug per se, but a requirement of every programming language I'm familiar with... you must distinguish levels of quotes to avoid confusion.

    In your case, you've already opened a single quote for the title= parameter and need to use the other kind of quote marks for the fields in the umbraco:item tag to avoid confusion about where the title= parameter ends.

     

    For what it's worth, it is also the case in "spoken" languages as well...

    You wouldn't write... He said, "it is also the case in "spoken" languages" as well"

    Rather, it would be written either as: He said, "it is also the case in 'spoken' languages as well"

    or as: He said, 'it is also the case in "spoken" languages as well'.

     

    Hope that helps clear up what's going on and why.

    cheers,
    doug.

  • AN 22 posts 42 karma points
    May 25, 2010 @ 18:16
    AN
    0

    Hi Doug,

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft