Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have:<iframe src="http://www.facebook.com/widgets/like.php?href=http://example.com" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe>I want to impl. this into my master template, but can anyone tell me what to write if I want the "http://example.com" change according to which page I'm on?e.g www.example.com/folder/my-biographyWhat I want is when people press my "Like" button it send the right url instead of 1 static like www.example.com.
I did this using XSLT like so (change iframe properties/url to fit your solution):
<iframe class="fb_like" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:85px; height:30px;" allowTransparency="true"><xsl:attribute name="src">http://www.facebook.com/plugins/like.php?href=http%3A%2F%2F<xsl:value-of select="umbraco.library:RequestServerVariables('HTTP_HOST')" /><xsl:value-of select="umbraco.library:UrlEncode(umbraco.library:NiceUrl($currentPage/@id))"/>&layout=button_count&show_faces=true&width=85&action=like&font=arial&colorscheme=light&height=30</xsl:attribute></iframe>
Maybe there's a better way but this worked like a charm for me.
Regards,Magnus
Essentially the same solution as Magnus
<xsl:if test="$currentPage/@id != ''"> <iframe src="http://www.facebook.com/widgets/like.php?href=http://{umbraco.library:RequestServerVariables('HTTP_HOST')}{umbraco.library:NiceUrl($currentPage/@id)}" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe> </xsl:if>
Create a new XSLT file, select 'clean' from the drop down (make sure you keep 'create macro' ticked)
Paste the code above between
<xsl:template match="/"><!--paste here--></xsl:template>
Then in your template just add the macro where ever you need the iFrame to appear.
Rich
Thank you both - I wonder why when I insert it in e.g master template using:
<umbraco:Macro Alias="FBlike" runat="server"></umbraco:Macro>It appears fine, but the rest of the page doesnt appear? ;)
Sounds like some tag is not closed correctly?
Maybe paste the HTML that is produced here.
Yeah .. this xslt<xsl:param name="currentPage"/><xsl:template match="/"><xsl:if test="$currentPage/@id != ''"> <iframe src="http://www.facebook.com/widgets/like.php?href=http://{umbraco.library:RequestServerVariables('HTTP_HOST')}{umbraco.library:NiceUrl($currentPage/@id)}&layout=button_count&show_faces=true&width=450&action=recommend&font=tahoma&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; width:450px; height:21px; overflow:hidden;" allowTransparency="true"> </iframe> </xsl:if>
</xsl:template>Output:<iframe src="http://www.facebook.com/widgets/like.php?href=http://www.mysite.com/da&layout=button_count&show_faces=true&width=450&action=recommend&font=tahoma&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; width:450px; height:21px; overflow:hidden;" allowTransparency="true" />It obviously removes the </iframe> and make a closing /> instead ..
Hi,
change your xslt a bit. By default it outputs xml, which does not like opening and closing tags with nothing in between. So, it makes it one tag.
To change this behaviour, change: xsl:output method="xml" into xsl:output method="html"
HTH,
Peter
Thats it! - solved .. than you all for being both fast and nice :-)
We're all just trying to spread the love for umbraco :)
But seriously, this is called the friendliest community in CMS-land. A lot of people around to give others a hand.
As return, you could mark one of the above answers as 'solution', so the guys that helped get a bit rewarded as well.
Cheers,
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
A simple dynamic URL in a template
I have:
<iframe src="http://www.facebook.com/widgets/like.php?href=http://example.com"
scrolling="no" frameborder="0"
style="border:none; width:450px; height:80px"></iframe>
I want to impl. this into my master template, but can anyone tell me what to write if I want the "http://example.com" change according to which page I'm on?
e.g www.example.com/folder/my-biography
What I want is when people press my "Like" button it send the right url instead of 1 static like www.example.com.
I did this using XSLT like so (change iframe properties/url to fit your solution):
Maybe there's a better way but this worked like a charm for me.
Regards,
Magnus
Essentially the same solution as Magnus
Create a new XSLT file, select 'clean' from the drop down (make sure you keep 'create macro' ticked)
Paste the code above between
Then in your template just add the macro where ever you need the iFrame to appear.
Rich
Thank you both - I wonder why when I insert it in e.g master template using:
<umbraco:Macro Alias="FBlike" runat="server"></umbraco:Macro>
It appears fine, but the rest of the page doesnt appear? ;)
Sounds like some tag is not closed correctly?
Maybe paste the HTML that is produced here.
Rich
Yeah .. this xslt
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:if test="$currentPage/@id != ''">
<iframe src="http://www.facebook.com/widgets/like.php?href=http://{umbraco.library:RequestServerVariables('HTTP_HOST')}{umbraco.library:NiceUrl($currentPage/@id)}&layout=button_count&show_faces=true&width=450&action=recommend&font=tahoma&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; width:450px; height:21px; overflow:hidden;" allowTransparency="true">
</iframe>
</xsl:if>
</xsl:template>
Output:
<iframe src="http://www.facebook.com/widgets/like.php?href=http://www.mysite.com/da&layout=button_count&show_faces=true&width=450&action=recommend&font=tahoma&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; width:450px; height:21px; overflow:hidden;" allowTransparency="true" />
It obviously removes the </iframe> and make a closing /> instead ..
Hi,
change your xslt a bit. By default it outputs xml, which does not like opening and closing tags with nothing in between. So, it makes it one tag.
To change this behaviour, change: xsl:output method="xml" into xsl:output method="html"
HTH,
Peter
Thats it! - solved .. than you all for being both fast and nice :-)
We're all just trying to spread the love for umbraco :)
But seriously, this is called the friendliest community in CMS-land. A lot of people around to give others a hand.
As return, you could mark one of the above answers as 'solution', so the guys that helped get a bit rewarded as well.
Cheers,
Peter
is working on a reply...