Keyword

Need to alter extra fields date output format

  • Justin Thomas
  • Justin Thomas's Avatar Topic Author
  • Offline
  • Senior Member
More
12 years 8 months ago #62009 by Justin Thomas
Need to alter extra fields date output format was created by Justin Thomas
I have just been using the extra fields date option for a project of mine. When I came to use the data in the front-end I realised that it was not following my Joomla! core format for the date. If you use the date published this is fine, but I am adding the additional fields to include the date of the course. The published and expiry dates are meaningless to the customer and the customer base for this client will not immediately understand

Y m d

I would rather the output read

l d F Y

I am bringing the output out using the following custom code as I don't need the full Additional Details (extra fields) on the category page (using category_item).
<?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?>
	  <!-- Item extra fields -->
	  <div class="catItemExtraFields">
<?php $custom = $this->item->extra_fields; ?>
	  	<ul>
			<li>
<span style="display:block;float:left;font-weight:bold;margin:0 4px 0 0;width:30%;font-weight: bold;"><?php echo $custom[0]->name; ?></span>
				<span style="font-weight: normal;"><?php echo $custom[0]->value; ?></span>
			</li>
			<li>
<span style="display:block;float:left;font-weight:bold;margin:0 4px 0 0;width:30%;font-weight: bold;"><?php echo $custom[1]->name; ?></span>
				<span style="font-weight: normal;"><?php echo $custom[1]->value; ?></span>
			</li>
			</ul>	    <div class="clr"></div>
	  </div>
	  <?php endif; ?>

Yes, I realise that my code could be a touch cleaner using class instead of style, but I am hacking right now and will clean this up later.

Please Log in or Create an account to join the conversation.

  • Justin Thomas
  • Justin Thomas's Avatar Topic Author
  • Offline
  • Senior Member
More
12 years 8 months ago #62010 by Justin Thomas
Replied by Justin Thomas on topic Re: Need to alter extra fields date output format
Solved it myself by bolting in the date format code from the original extra fields code.
<?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?>
	  <!-- Item extra fields -->
	  <div class="catItemExtraFields">
<?php $custom = $this->item->extra_fields; ?>
	  	<ul>
			<li>
				<span style="font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;font-weight: normal;font-size:11px;"><?php echo ($custom[0]->type=='date')?JHTML::_('date', $custom[0]->value, JText::_('K2_DATE_FORMAT_LC')):$custom[0]->value; ?> from <?php echo $custom[1]->value; ?></span>
			</li>
			</ul>	    <div class="clr"></div>
	  </div>
	  <?php endif; ?>

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum