Search

Hi folks,

i’m trying to display the todays weekday (like “Monday”) via the date-time utility, but i don’t get it right.

I’d like to use the params to pass the weekday number to the date-time utility so that i get the weekdays name.

Can anybody help?

Could you post your current XSL, please?

Sure, i tried it like this:

<xsl:call-template name="format-date">
   <xsl:with-param name="date" select="$today"/>
   <xsl:with-param name="format" select="'W'"/>
</xsl:call-template>

But with “W” as the format, symphony throws an error like this:

XSLTProcessor::transformToXml(): Failed to evaluate the expression of variable 'weekday'.

I tried several ways to hand the $this-day parameter to the date-time utility, but it didn’t work, because date-time expects xml like this:

<datum time="11:42" weekday="6">2009-10-03</datum>

EDIT: Just realized that $this-day is not the weekday (1-7), but the day of the month (1-31). That takes my problem to an even higher level. Where do i get the weekday from?

Maybe you should take a look a EXSLT.

I used this function recently, which is a more ‘friendly’ output of Nils’ link.

Day Name

To just use the

<xsl:value-of select='date:day-name()' />

You’ll need to the add the date namespace to your XSLT too

Thank you very much for your help. Because the weekday thing is a very little piece of the website, i was a bit shy to implement such a sophisticated template. So i did the following: I added this line to the symphony/lib/toolkit/class.frontendpage.php (line 184):

'this-weekday' => DateTimeObj::get('l'),

That gives me the current weekday like “Monday” as a param named $this-weekday. Because i need the whole thing in german i implemented it like this:

<xsl:if test="$this-weekday = 'Monday'">Montag</xsl:if>
<xsl:if test="$this-weekday = 'Tuesday'">Dienstag</xsl:if>
<xsl:if test="$this-weekday = 'Wednesday'">Mittwoch</xsl:if>
<xsl:if test="$this-weekday = 'Thursday'">Donnerstag</xsl:if>
<xsl:if test="$this-weekday = 'Friday'">Freitag</xsl:if>
<xsl:if test="$this-weekday = 'Saturday'">Samstag</xsl:if>
<xsl:if test="$this-weekday = 'Sunday'">Sonntag</xsl:if>

I think that’ll do it for a while. Not the finest solution, but it fits my needs at the moment. Thanks again for your replies!

You should be able to use the Global Parameter Loader to achieve this a little more neatly. Something like:

return date("l", time());

You’ll still need the utility but at least you’re not hacking your core files this way.

Thanks a bunch Makenosound! I felt guilty to change code from the core. This is just perfect! I’ll definitely give it a try.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details