Display Template Field Formatting

Is it possible to format the way the date is displayed in content?

eg. I have {$date}, the field is a datepicker, I just want the month and year displaying.....

  • Changing the datepicker format is possible so long as it does not confuse the PHP strtotime function.

    But it would require some custom coding as there is no option for that through the web.


  • @Mick - welcome backk from your craziest UK winter in 30 years' hibernation ;-) Throw me a screen shot of *your date field - display of only MMM YY -> can be patch fixed with JS.. a few lines of code, easy stuff [ call it lateral out of the box thinking or more properly - the DDS taxonomy for efficient code patches ;-P ]

  • Hello again Mr. DeScoop (been away from elgg for a while) - Yeah, I suppose winter has been a bot harsh, but to be honest, last year was much worse.

    My customer has settled on a simpler solution (which actually helps me out because the date picker was taking ages to display).

    Using Kevins forms plugin, I'd created a simple content form which included a 'date' field. My customer wanted only the Month and Year displaying in the content view. I'm not sure if you're familiar with Kevin's Forms plugin, but the 'Template' function allows you to add your own layout - see example below:

    <p> </p>
    <p> </p>
    <p><div align="center">{$title}</div></p>
    <p> </p>
    <p><div align="center">{$image:thumb:large}</div></p>
    <p> </p>
    <p><div align="center"><h3>{$text}</h3></div></p>
    <p> </p>

    I wondered if it was possible to add something simple to '{$date}' field as with the '{$image}' field?

    Good to hear from you again and I hope to be back for a while : )


  • you mean ?


    need to show me a screenshot of that code actually displaying something - then can work out some JS or PHP for diff date display formatting.


  • Don't worry too much buddy. I have persuaded my customer to have 2 drop-down fields instead; one for Month and one for Year.

    MyWork Template Dump


    This is how the form is displayed:

    MyWork Display Dump

  • March 12, 2011
    If the 'template' is php code ;-)

    before the template html
    or using <?php and ?>

    gives you the first part - Mmmmm DD and you can still use the DatePicker's popup.

  • lolz ;-) you gotta say that it works ! ;-X

Form and related plugins

Form and related plugins

User-generated content, flexible user and group profiles, registration forms, custom file forms