Keyword

Only Show Read More if Article has ReadMore Divide

  • Ron Adams
  • Ron Adams's Avatar Topic Author
  • Offline
  • New Member
More
12 years 9 months ago #61167 by Ron Adams
I want the read more link to only show if the article actually has a manually inserted readmore divider. Is there a way to do this?

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

  • Lance Thompson
  • Lance Thompson's Avatar
  • Offline
  • New Member
  • Making the Web Work For You
More
12 years 6 months ago #61168 by Lance Thompson
Replied by Lance Thompson on topic Re: Only Show Read More if Article has ReadMore Divide
Hi Ron,

Did you ever find a solution to this? I too have a client who has a ton of articles, some of them very short and some that have the "Read More" divider set within the content. I only want the read more to show IF there's a read more tag inserted.

The way it works now is that it's either show or not. Period.

Thanks!

Lance Thompson - Blue Sky Web Worx
Web Design, SEO, Graphic Design
www.BlueSkyWebWorx.com

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

More
12 years 6 months ago #61169 by william white
Replied by william white on topic Re: Only Show Read More if Article has ReadMore Divide
A custom override will be needed to do this
you will need to search category_item.php for <?php if ($this->item->params->get('catItemReadMore')): ?>
Place a test for the existance of fulltext around it

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

More
12 years 5 months ago #61170 by Darryll
I'm trying to do the same thing as the OP, and someone did post the override code on the old forum way back. I'm playing around in category_item.php, but I'll admit that PHP isn't my strongest point so I'm a little stuck in finding the right code myself.

I added another if statement inbetween the current block and tried replacing get('catItemReadMore') with all the ideas I had, and the closest I got was hiding it completely when an item actually has fulltext (which isn't very helpful as it's every time, i think).

I also tried adapting the if(!empty statement from the comments counter section, and while I didn't get very far I think if!empty might be where I'm falling down.

William - Could you please post a little code so I can get my head around where I'm going wrong please? Usually I'm OK with the smaller template overrides, but this one is just that little bit over my head.

Thanks in advance, and this is a pretty long winded post to ask a really simple question

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

More
12 years 5 months ago #61171 by william white
Replied by william white on topic Re: Only Show Read More if Article has ReadMore Divide
Im sorry i dont have the code at the moment. I dont have access to the old posts either
The php empty will return results that may be misleading
Mabee you should test for the length php strlen and see if the length of the fulltext is greater than some amount.
I would start getting the syntax correct by reporting the srtlen to the screen in the override just after the readmore shows. If there is full text there should be a number there, then you can see what is returned if there is no fulltext.
next, put a if around the readmore code testing for the length > amount to display the readmore....endif

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

More
12 years 5 months ago #61172 by Aaron
Here is the code from the default K2 template:
					

Aaron :)

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

More
12 years 5 months ago #61173 by william white
Replied by william white on topic Re: Only Show Read More if Article has ReadMore Divide
@aron, i think that only turns the display of the readmore button on and off

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

More
12 years 5 months ago #61174 by Darryll
Hey folks,

I dug a little deeper and I found the code in a backup of an old site. Just tested on a Joomla 2.5.4 / K2 2.5.6 install and it worked just fine.

category_item.php
<?php if ($this->item->params->get('catItemReadMore')): ?>

replace with
<?php if ($this->item->params->get('catItemReadMore') && ($this->item->fulltext != "")): ?>

Thanks all the same for the replies and I hope this helps :)

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

More
11 years 6 months ago #61175 by Manuel Kuhs

Darryll wrote: Hey folks,

I dug a little deeper and I found the code in a backup of an old site. Just tested on a Joomla 2.5.4 / K2 2.5.6 install and it worked just fine.

category_item.php

<?php if ($this->item->params->get('catItemReadMore')): ?>

replace with
<?php if ($this->item->params->get('catItemReadMore') && ($this->item->fulltext != "")): ?>

Thanks all the same for the replies and I hope this helps :)


I did the above on Joomla 2.5.8 / K2 2.6.5 in file components/com_k2/templates/default/category_item.php and it did NOT work.

Anyone any ideas?

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

More
11 years 3 months ago #61176 by Kelsey Brookes
Replied by Kelsey Brookes on topic Re: Only Show Read More if Article has ReadMore Divide
I'm on 2.6.6 and 2.5.11 and this worked perfectly for me.

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


Powered by Kunena Forum