I have the following XSLT in my Umbraco V4 website that allows me to put in a search engine optimised page title if I enter one but shows the umbraco page title if I don't enter one, this works fine if the page has the property seopagetitle but if I have a page that doesn't have that property or a page that hasn't been published since I added the seopagetitle to that document type then it doesn't show the Umbraco page title which is what I want. Basically I need the XSLT to check if the node has got nothing specified for the seopagetitle or doesn't even have the seopagetitle property. Can someone tell me how or if I can do this, this is what I have so far:
I do something similar. I have a the following fields in my generic properties doctype: Page Title and Remove Sitename from Page Title. My home page then has a field name sitename. Basically it uses either Page Title (if it exists) otherwise it uses Node Name. If the Remove Sitename from Page Title is not checked, then it will add the sitename afterwards. Otherwise, it will just display the page title.
Thanks for the reply Chad the problem I have is with the pages that do not have the extra property field "seopagetitle" or ones that "seopagetitle" has recently been added to their doctype but the page has not been republished since (hence in the database they still don't have a property called seopagetitle).
Because these pages don't have seopagetitle equally nothing (they just dont have seopagetitle full stop) they do not instead use the Umbraco page title.
Therefore I need a way to check if the pages have "seopagetitle" equally nothing OR they do not have the property "seopagetitle" what so ever.
If your page might not have the property you're checking against you just need to handle that. The easy way is to use the string() function, which will return an empty string if the property has no value or if the property doesn't even exist. The ultimate error handler :)
But if this is all the macro is doing you could just as easily handle it with the "Insert umbraco page field" button in the template editor's toolbar. You would simply select the following parameters:
Choose field = seopagetitle
Alternative field = @pageName
This will create the following line in your template:
I wanted to use the umbraco Item's useIfEmpty property before for the page title, but found out it doesn't really work... I'm not able to explain more about the problem I had, because I forgot. But I think the problem was, that if the pageTitle property was empty (''), it still uses the pageTitle property instead of the pageName...
Sorry for not responding sooner on this, been busy with Christmas etc, I managed to get it to work with Chad's suggestion but I changed <xsl:else> to <xsl:otherwise> as shown below, thank you all for your help on this problem and happy new year to you all.
Search engine optimisation page title
Hi,
I have the following XSLT in my Umbraco V4 website that allows me to put in a search engine optimised page title if I enter one but shows the umbraco page title if I don't enter one, this works fine if the page has the property seopagetitle but if I have a page that doesn't have that property or a page that hasn't been published since I added the seopagetitle to that document type then it doesn't show the Umbraco page title which is what I want. Basically I need the XSLT to check if the node has got nothing specified for the seopagetitle or doesn't even have the seopagetitle property. Can someone tell me how or if I can do this, this is what I have so far:
I do something similar. I have a the following fields in my generic properties doctype: Page Title and Remove Sitename from Page Title. My home page then has a field name sitename. Basically it uses either Page Title (if it exists) otherwise it uses Node Name. If the Remove Sitename from Page Title is not checked, then it will add the sitename afterwards. Otherwise, it will just display the page title.
Hope this makes sense.
Thanks for the reply Chad the problem I have is with the pages that do not have the extra property field "seopagetitle" or ones that "seopagetitle" has recently been added to their doctype but the page has not been republished since (hence in the database they still don't have a property called seopagetitle).
Because these pages don't have seopagetitle equally nothing (they just dont have seopagetitle full stop) they do not instead use the Umbraco page title.
Therefore I need a way to check if the pages have "seopagetitle" equally nothing OR they do not have the property "seopagetitle" what so ever.
ahh....sorry about that. So if I'm clear, the XSLT is not working if SEOpagetitle doesn't exist at all on the page.
If this is the case, then your if if statement won't work because they're checking the same field that fails.
Did you try a choose statement?
<xsl:choose>
</xsl:choose>
Didn't test, but this should work....(famous last words).
If your page might not have the property you're checking against you just need to handle that. The easy way is to use the string() function, which will return an empty string if the property has no value or if the property doesn't even exist. The ultimate error handler :)
I'd use the following in xslt...
But if this is all the macro is doing you could just as easily handle it with the "Insert umbraco page field" button in the template editor's toolbar. You would simply select the following parameters:
Choose field = seopagetitle
Alternative field = @pageName
This will create the following line in your template:
Hope this helps.
cheers,
doug.
@Douglas
I wanted to use the umbraco Item's useIfEmpty property before for the page title, but found out it doesn't really work... I'm not able to explain more about the problem I had, because I forgot. But I think the problem was, that if the pageTitle property was empty (''), it still uses the pageTitle property instead of the pageName...
Hi,
Sorry for not responding sooner on this, been busy with Christmas etc, I managed to get it to work with Chad's suggestion but I changed <xsl:else> to <xsl:otherwise> as shown below, thank you all for your help on this problem and happy new year to you all.
is working on a reply...