Support Forums

Change format in "date field" extra field

This is a discussion on Change format in "date field" extra field within the Technical Support forums, part of the Technical Support Forums category; In the Regional settings you can change the date format for the site and admin. Is there also a way ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

This topic is resolved.

If you have a similar issue that this thread does not address, open a new related support topic.

 
Thread Tools Display Modes
Old 04-26-2008, 08:21 AM   #1
Member
 
Join Date: Mar 2006
Posts: 26
Rep Power: 23
topbidz is on a distinguished road
Default Change format in "date field" extra field

In the Regional settings you can change the date format for the site and admin. Is there also a way to change the format when you use the "date field" type in the extra fields?

Now mine is set to display like this: 2008-04-18 and I would like it to display like this: April 18, 2008
topbidz is offline  
Old 05-01-2008, 07:57 AM   #2
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

What you can do is go to administration and get the field id you are wanting to format.

Next open the template file and locate the section that looks like this:
Code:
{* Extra Fields *}
            {foreach from=$extrafields item=extras}
            <tr>
                <td><strong>{$extras.title}:</strong></td>
                <td>
                    {if isset($extras.value)}
                      {foreach key=key item=item from=$extras.value}
                        {$item}<br />
                        {foreachelse}
                        {$extras.value}
                      {/foreach}
                     {/if}
                </td>
            </tr>
            {/foreach}
            {* End Extra Fields *}
Then add an if like this:

Code:
{* Extra Fields *}
            {foreach from=$extrafields item=extras}
            <tr>
                <td><strong>{$extras.title}:</strong></td>
                <td>
                    {if isset($extras.value)}
                      {foreach key=key item=item from=$extras.value}
                          {if $extras.fID==3}
                          {$item|date_format:$dateformat}<br />
                          {else}
                        {$item}<br />
                        {/if}
                        {foreachelse}
                        {$extras.value}
                      {/foreach}
                     {/if}
                </td>
            </tr>
            {/foreach}
            {* End Extra Fields *}
Where 3 is the field id you want to format.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 05-01-2008, 07:38 PM   #3
Member
 
Join Date: Mar 2006
Posts: 26
Rep Power: 23
topbidz is on a distinguished road
Default

Hi Eric

I added the code but get the following error message:

Fatal error: Smarty error: [in viewlisting2.tpl line 131]: syntax error: mismatched tag {/foreach}. expected {/if} (opened line 127). (Smarty_Compiler.class.php, line 2300) in /home/lixqwyiv/public_html/includes/classes/smarty/Smarty.class.php on line 1095

Not sure where I went wrong.

Also I have 2 date fields to change, a start date and an end date. How would I add in the second field?

Thanks

John
topbidz is offline  

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0