Keyword

Need help with display modified date, if it exists

More
11 years 6 months ago - 11 years 6 months ago #111252 by Lee
My initial plan seems to me to be quite simple, however now I'm thinking maybe it's not.

So just to introduce my idea, firstly I should say I'm working with the K2 Content module.

Working with the original default.php file, I'm using the same method it uses by default for showing each item in a <li>, but I've turned off the alternating background colour.

So, in the attachment I've tried to demonstrate ideally what I'd like the output to be.

So first things first:

1. If the item has been modified, show the modified date. If it hasn't, show the created date.

2. Show the itemTitle, and a link to the item page (I can do this fine)

3. Show the category belonging to the item and link to it (I can also do this fine)

4. If there is a value present in a specific extra field, show it here. If there is nothing in the extra field, but the item has a modified date, show 'No revision notes'. If there is nothing in the extra field, and the item doesn't have a modified date, show 'Item added'.

I can get each part to show fine, it's just the if statements that I can't seem to get, and would just like someone who knows the structure of if statements and calling the relevant K2 items to give a helping hand.

Any questions, I'd be glad to answer!

PS. It won't let me upload file attachments. After file dialogue box appears and I click a file and click open, nothing happens.

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

More
11 years 6 months ago - 11 years 6 months ago #111253 by Lee
Attached files below. It seems to be FireFox that doesn't allow files to be attached.
Attachments:

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

More
11 years 6 months ago #111254 by Lee
Here's a copy of the default.php file I'm working with. I've stripped out all the other parameters that aren't being used.
Log in  or Create an account to join the conversation.

More
11 years 6 months ago #111255 by Lee
Anyone at all? :|

Surely there'd be at least one person who could easily do this??

I'm amazed

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

More
10 years 5 months ago - 10 years 5 months ago #111256 by Johnny B
First part:

<div class="catItemHeader">
<!-- Date modified -->
<?php if ($this->item->modified <> '0000-00-00 00:00:00'): ?>
<span class="catItemDateModified">
<?php echo JHTML::_('date', $this->item->modified , JText::_('DATE_FORMAT_LC4')); ?>
</span>
<?php else: ?>
<span class="catItemDateModified">
<?php echo JHTML::_('date', $this->item->created , JText::_('DATE_FORMAT_LC4')); ?>
</span>
<?php endif; ?>
</div>

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

More
10 years 5 months ago #111257 by Lefteris
The code of Johnny B should work. Regarding extra fields you can always use the extra field alias. It was introduced in K2 2.6.2 . You can read more regarding this at getk2.org/blog/1068-k2-v262-now-available.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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