fbpx
Flat 60% off on Everything
Days
Hrs
Welcome, Guest
Username: Password: Remember me

TOPIC: Pbulhsed date in blog - display year.

Pbulhsed date in blog - display year. 2 years 10 months ago #5847

  • pete
  • pete's Avatar
  • Offline
  • Senior Member
  • Posts: 62
  • Thank you received: 1
  • Karma: -3
HI, is there a way to show the year as well in the blog categories.
if you look at :
demo.joomdev.com/medical/toolbar/index.php/blog

the article has date 27/Jun in the right top corner of the image. I would like to display the year as well.

Thanks,
Peter
The administrator has disabled public write access.

Pbulhsed date in blog - display year. 2 years 10 months ago #5858

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 4235
  • Thank you received: 620
  • Karma: 112
Hi Peter,

This is surely possible by modifying some code here and there.
A little background on this. The Blog page is built using K2, Below I am going to provide you overrides code for K2 category item layout (lists items on blog page) and K2 item (Individual Blog items).

Blog layout example: demo.joomdev.com/medical/toolbar/index.php/blog
Individual Item layout example : demo.joomdev.com/medical/toolbar/index.p...-green-cleaning-goal

You need to modify the following files:
templates/jd_medical/html/com_k2/templates/default/category_item.php
Go around line: 40, change the code for div catItemDateCreated from
<span class="catItemDateCreated">
			<span class="date"><?php echo JHTML::_('date', $this->item->created , JText::_('d')); ?></span>
			<span class="month"><?php echo JHTML::_('date', $this->item->created , JText::_('M')); ?></span>
		</span>

to:
<span class="catItemDateCreated">
			<span class="date"><?php echo JHTML::_('date', $this->item->created , JText::_('d')); ?></span>
			<span class="month [b]date[/b]"><?php echo JHTML::_('date', $this->item->created , JText::_('M')); ?></span>
			[b]<span class="year"><?php echo JHTML::_('date', $this->item->created , JText::_('Y')); ?></span>[/b]
		</span>
So, To give you a background on what I did above, added the date class in the month span, so you get the bottom border (separator between month and year).
Added the year span to display the year.

Same changes are to be done in file item.php in the same directory around line 83 (search for div itemDateCreated).

and replace code:
<span class="itemDateCreated">
			<span class="date"><?php echo JHTML::_('date', $this->item->created , JText::_('d')); ?></span>
			<span class="month"><?php echo JHTML::_('date', $this->item->created , JText::_('M')); ?></span>
		</span>

with:
<span class="itemDateCreated">
			<span class="date"><?php echo JHTML::_('date', $this->item->created , JText::_('d')); ?></span>
			<span class="month"><?php echo JHTML::_('date', $this->item->created , JText::_('M')); ?></span>
			<span class="year"><?php echo JHTML::_('date', $this->item->created , JText::_('Y')); ?></span>
		</span>

Here is a screenshot of what it looks like:
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
Last Edit: 2 years 10 months ago by admin.
The administrator has disabled public write access.
The following user(s) said Thank You: pete

Pbulhsed date in blog - display year. 2 years 10 months ago #5865

  • pete
  • pete's Avatar
  • Offline
  • Senior Member
  • Posts: 62
  • Thank you received: 1
  • Karma: -3
Nice,
thanks...

one small correction. in your code for catItemDateCreated you have:

[b]<span class="year"><?php echo JHTML::_('date', $this->item->created , JText::_('Y')); ?></span>[/b]

the and showed up on the page, so removing them does the trick...

cheers.
Peter

One more thing. I'm trying to change the blog menu behaviour. When I open blog (top menu), I want to see all articles regardless of category, sorted by latest first.
The categories can be still open from the list on the right. I had partial success, where I change the Blog menu to list all articles form all categories. It still gives me the articles by categories but there are all of them. Btw, the date in the corner is not visible in this mode. I'm not sure, which file I need to update.
The administrator has disabled public write access.

Pbulhsed date in blog - display year. 2 years 10 months ago #5866

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 4235
  • Thank you received: 620
  • Karma: 112
Glad, the date issue worked out Pete.

I'll test the issue about all categories too and see if that is something that can be fixed in the next release of the template.

For the movement, I'd recommend keeping the menu item to list by categories/user by selecting all categories instead. In this case, the ordering settings are then taken over by menu and not individual category and you will have easier time managing the ordering of the items displayed on the page.
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The administrator has disabled public write access.

Pbulhsed date in blog - display year. 2 years 10 months ago #5871

  • pete
  • pete's Avatar
  • Offline
  • Senior Member
  • Posts: 62
  • Thank you received: 1
  • Karma: -3
Yep,
that's what I'm doing. I did list by categories. It's not perfect, but it has to do for now. Btw, when I do that it doesn't show the date in the corner... Is this menu driven by different template?
Pete
The administrator has disabled public write access.

Pbulhsed date in blog - display year. 2 years 10 months ago #5876

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 4235
  • Thank you received: 620
  • Karma: 112
Should be the same template Pete. I'll give it another try and see if there is anything that needs update and get that out of the way.

Thanks,
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The administrator has disabled public write access.
Moderators: chandandeep
Time to create page: 0.377 seconds