That line of code returns empty it seems. Which means It can't get the property out which is really weird because outside this macro, in the HTML I use this to get the postDate
it returns the right date and time but I need to format it and the above line of code won't work. If you look at the whole macro I have posted - 'postDate' is a variable and 'PostDate' is the property from the DocType.
Trouble getting PostDate in XSLT
Hi, I am trying to make a macro that calculates how long ago a blog post has been posted.
The problem is when I try to get the current blogpost date.
Here is the code:
The error is placed at
currentPage/@PostDate
and it says:Isn't it supposed to run well since I have mentioned the context?
You're missing "$" infront of your "currentPage".
Should be:
Could that be the error?
I tried that aswell, same error.
Assuming postDate is a DocType property:
The DocType property is PostDate. Still, I get the same thing.... even without using "@"
make sure you can get the property out first, one step at a time, what does this return?
<xsl:value-of select="$currentPage/postDate"/>
Hi again,
Maybe you need to wrap an if around, not all pages have the @postDate attribute.
The "FormatDateTime", doesn't like to be called without a date :)
@Rich Green
That line of code returns empty it seems. Which means It can't get the property out which is really weird because outside this macro, in the HTML I use this to get the postDate
@Kim Nedergaard
It doesn't help. It only makes the error go away by skipping those few lines of code.
This is what the macro looks like entirely:
Can you post a snippet from your /App_Data/umbraco.config file of a line that contains postDate
This one?
yes, you need to be using
<xsl:value-ofselect="$currentPage/PostDate"/>
This is what I need:
If I try this:
it returns the right date and time but I need to format it and the above line of code won't work. If you look at the whole macro I have posted - 'postDate' is a variable and 'PostDate' is the property from the DocType.
As Kim's solution one the previous page:
The editor messed up the code:
(note the corrected $currentPage/PostDate)
Error strikes at this line now:
Oups, fixed it. I surrounded the whole choose with the IF statement.
Seems to be working now!
Thanks you very much!
No problem, glad you got it sorted, remember to mark the solution as solved as it helps others too :)
Should I post the solution myself? The whole macro, just so others can use it aswell?
No, sorry, there's a little tick where you can mark the solution as solved (next to the post that solved the issue)
is working on a reply...