Another quick question! How to work with a Twitter feed's created-at date?
This is an open discussion with 10 replies, filed under Troubleshooting.
Search
You could have a look at one of the date utilities or use JavaScript to set up relative dates.
You can break-up the created_at
element into more manageable pieces or reformat it using XPath’s string functions. Try substring()
.
Not related to the date, but you should check out the Twita@talinkahashifyer utility for Twitter content, too.
I’m not entirely sure how to use some of these XSLT utilities! I’ll definitely have a bash at using substring(), that looks like something I can work with. Thanks for the responses guys!
To do relative times, have a look at this exslt function.
Actually, even better – somebody might have already done it for you. Check out this thread.
Ooooh, perfect! I’ll give it a whirl!
Gah, it would appear that I still have no idea how to use utilities. How would I use that utility on the date and place it on the page?
All I’ve managed so far is this, which is possibly correct:
<span class="twitter-date"> <xsl:call-template name="twitter-date-formatter"> <xsl:with-param name="date" select="created_at"/> </xsl:call-template> </span>
But I’m getting this error at the moment, and I can’t see why:
XSLTProcessor::transformToXml(): runtime error: file /Users/robertmay/Dropbox/Programming/safleswyddicms/workspace/utilities/twitter.xsl line 18 element call-template
I still have a lot to learn it would appear!
Did you import your utility that contains the twitter-date-formatter
template?
I did, and I just found the problem. Essentially, I’m a numpty.
I was calling:
<xsl:call-template name="twitter-date-formatter">
when it should be:
<xsl:call-template name="twitter-format-date">
All fixed! Thanks for the input everyone. The community is incredibly helpful here. :)
Create an account or sign in to comment.
I’ve been asked to integrate a Twitter feed on the homepage for this project, and I’ve already got it pulled in as a Dynamic XML DS and displaying on the page. However, this is the format of the feed’s date:
I’m hoping to use nickdunn’s time ago/since XSLT to present the date more how it appears on the Twitter website, but their date is in a rather different format. I could work with it in PHP, but is there a way to compare it to the current date in XSLT?