<xsl:template name="AddThis">
<div class="AddThis">
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style" addthis:url="{be:GetFullBlogUrl(#Date, #Title)}" addthis:title="{#Title}" xmlns:addthis="http://www.addthis.com">
<a class="addthis_button_facebook_like" fb:like:width="115"> </a>
<a class="addthis_button_tweet"></a>
<a class="addthis_counter addthis_pill_style addthis_nonzero"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f86b27a69737a92"></script>
<!-- AddThis Button END -->
</div>
</xsl:template>
I need to add the fb:like:width="115" according to
http://support.addthis.com/customer/portal/articles/125587-facebook-like-button-width#.UZyl2rVM_2P
but the xsl transformation of course can't figure that out, due to namespaces issues.
Any idea how to resolve it? Any option to just write out plain text.
AFAIK there is no way to generate an attribute with 2 colons (a single colon fb: can be processed using a normal xmlns alias prefix).
So instead, you can render a literal using xsl:text with disable-output-escaping="yes", like so:
<xsl:text disable-output-escaping="yes">
<a class="addthis_button_facebook_like" fb:like:width="115"> </a>
</xsl:text>
Output:
<a class="addthis_button_facebook_like" fb:like:width="115">
Related
I am trying to use a loop iteration in xslt. I want to loop through all the text with tei of "orgName", and generate a different popover-body for each one. I hope it would be something like (div class="Org-popover-body-1),(div class="Org-popover-body-2)... What should I put in ??? Thanks beforehand.
<xsl:template match="tei:orgName">
<xsl:for-each select="orgName">
<a class="orgName" id="orgNameinfo" data-toggle="popover-2" data-trigger="fcours" data-popover-content-2="#a2" data-placement="right">
<xsl:attribute name="href">
<xsl:text>#</xsl:text>
<xsl:value-of select="#key" />
</xsl:attribute>
</a>
<div id="a2" class="hidden">
<div class="popover-heading2">Orgnization Information <span style="float:right;cursor:pointer;" class="fa fa-times" data-toggle="popover"></span>
</div>
<div class="Org-popover-body-???">
</div>
</div>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:template>
I think what you need are Attribute Value Templates, so you would write this...
<div class="Org-popover-body-{position()}">
You probably want to do this in the id of the hidden div to (to avoid multiple divs with the same id)
<div id="a{position()}" class="hidden">
And similarly in the data-popover-content-2 attribute
... data-popover-content-2="#a{position()}" ...
I need to modify on-the-fly the "content" side of a tag appending some text.
I have (on the content side) the classic portal-tabs:
<ul class="nav" id="portal-globalnav">
....
<li id="portaltab-events" class="plain">
Eventi
</li>
</ul>
I need to append (via diazo) on-the fly the content of another tag (#numbers) to obtain something like:
<ul class="nav" id="portal-globalnav">
....
<li id="portaltab-events" class="plain">
Eventi
<div id="#numbers">33</div>
</li>
</ul>
How solve this issue?
Thank's
You might see if this helps: http://docs.diazo.org/en/latest/recipes/modifying-text/index.html
Also, where does the #numbers div come from? If you append it to each LI tag, you'll have an invalid HTML (more than one element with the same ID)
A content replace containing a little XSL should do it.
<replace css:content="#portaltab-events a">
<xsl:copy-of select="." />
<xsl:copy-of select="//*[#id='numbers']" />
<xsl:apply-templates />
</replace>
If you separately drop the #numbers div, you'll need to add mode="raw" to the apply-templates to prevent it from being dropped here.
I'm pretty new to umbraco but found the system pretty easy to use and have done alot in a short space of time. One difficulty I have come accross is displaying an image.
In the document type I have added an "upload" where an image is selected.
In my XSLT I loop through the pages, this loop displays the other fields such as description or title. I am trying to display the image here.
Here is my XSLT for displaying my image, this displays nothing. The field "promothumbImage" is defined in the document type, as I said everything else is working fine.
<xsl:value-of select="promothumbImage"/>
Does anyone have any ideas as to where I am going wrong?
EDIT:
promothumbimage is defined in the document of type "upload"
My XSLT:
<!-- The fun starts here -->
<div class="promoitems">
<xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [#isDoc and
string(umbracoNaviHide) != '1']">
<div class="promoitem">
<a href="{umbraco.library:NiceUrl(#id)}">
<xsl:value-of select="#nodeName"/>
</a>
<div class="promosmalldesc">
<xsl:value-of select="promoSmallDesc"/>
</div>
<xsl:copy-of select="promothumbImage/*"/>
</div>
</xsl:for-each>
Upload means that the element promothumbImage returns the URL of the image, thus the following should display it on the page:
<img src="{promothumbImage}" alt=""/>
I found the answer, use:
<img src="{promothumImage}" />
to display the image from the "upload" set in the document type
use may simply in your template using your image field throght Media picker Data Type:
<img class="className" src='<umbraco:Item field="infoGraphic" runat="server" Xslt="umbraco.library:GetMedia({0},false())/umbracoFile"/>'/>
Ok so this is my xslt for looping through the items of the home item, but I would like to be able to loop through the template... The reason for this is so that my xslt can be more specific instead of showing everything under the home item
<xsl:template match="*" mode="main">
<div id="aside">
<ul id="nav">
<xsl:for-each select="$home/descendant-or-self::item[position() <= 6]">
<li>
<sc:link>
<sc:text field="Title"></sc:text>
</sc:link>
</li>
</xsl:for-each>
</ul>
<div class="advertisement">
<sc:image field="Image"></sc:image>
</div>
</div>
</xsl:template>
From your xslt it seems you are talking about the navigation. Instead of looping through different templates I would create a specific Navigation template that has only one field called ShowInNavigation.
Then all your other templates will inherit this one and the navigation xslt will become simpler
<xsl:template match="*" mode="main">
<div id="aside">
<ul id="nav">
<xsl:for-each select="$home/descendant-or-self::item[sc:fld('ShowInNavigation') = '1']">
<li>
<sc:link>
<sc:text field="Title"></sc:text>
</sc:link>
</li>
</xsl:for-each>
</ul>
<div class="advertisement">
<sc:image field="Image"></sc:image>
</div>
</div>
</xsl:template>
Also don't use descendant-or-self::item in the navigation because as the site grows the navigation will become your bottleneck.
Better use $home/item[sc:fld('ShowInNavigation') = '1'] and then hardcode the home node above. So the xslt will become:
<xsl:template match="*" mode="main">
<div id="aside">
<ul id="nav">
<li>
<sc:link select="$home">
<sc:text field="Title"></sc:text>
</sc:link>
</li>
<xsl:for-each select="$home/item[sc:fld('ShowInNavigation') = '1']">
<li>
<sc:link>
<sc:text field="Title"></sc:text>
</sc:link>
</li>
</xsl:for-each>
</ul>
<div class="advertisement">
<sc:image field="Image"></sc:image>
</div>
</div>
</xsl:template>
Using XSLT, I'd like to be able to transform this :
<doc>
<tag1>AAA</tag1>
Hello !
<tag2>BBB</tag2>
</doc>
into this :
<div class="doc">
<div class="tag1">AAA</div>
Hello !
<div class="tag2">BBB</div>
</div>
...but without specifying explicitly any tag name in the stylesheet (there are too many in the real world)
What would be the best way to do this ?
Something along the lines of
<xslt:template match="*">
<div class="{local-name()}">
<xsl:apply-templates />
</div>
</xslt:template>