0

I am looking to create a 'View all ' button on the article page.

For instance if someone views the blog layout of a category and then views an article, I am looking for a Back to blog category view button from the article itself.

I do not want to use the default, show category/link category which can be displayed at the bottom of the article as it is styled incorrectly and shows: Details: Category : link.

I have an article component override already. Whats the best way to add a back/view all article link.

  • but it's easy to style and tweak the current category link the way you want. – FFrewin Feb 28 '15 at 17:14
  • What override do I need for that ? – StuartM Feb 28 '15 at 18:13
  • :: See answer below. – FFrewin Feb 28 '15 at 18:31
1

What override do I need for that ?

Create an override for the articles layout. Inside the html folder of the template, create a folder named "com_content", then another one "article" and copy there the article.php from components->com_content->views->article->tmpl.

Then inside the copied article.php file, something like the code below would work. Place it where you want the button to display:

<div class="view-all-btn btn button">
    <?php $catTitle = $this->escape($this->item->category_title); ?>
    <?php echo '<a href="' . JRoute::_(ContentHelperRoute::getCategoryRoute($this->item->catslug)) . '" itemprop="genre" title="' . $catTitle . '">View All</a>'; ?>
</div>

Update / Answer to your comment:

Q: how do I control which categories this shows for?
Then you could connect the appearance of the view-all button with the settings of show category and link to category. Find inside the article.php the part of the code that is printing the category title and link and modify its html output to suit your needs, but keep its checking from the backend settings, so you can control from the admin when it will be shown.

  • Thanks and how do I control which categories this shows for. Ie if it's uncategorised I wouldn't want the button to show – StuartM Feb 28 '15 at 18:45
  • Then you could connect the appearance of the view-all button with the settings of show category and link to category. Find inside the article.php the part of the code that is printing the category title and link and modify its html output to suit your needs, but keep its checking from the backend settings, so you can control from the admin when it will be shown. – FFrewin Feb 28 '15 at 19:36
  • I think I saw that the code to include the category title and link was not looking at the category_link variable it's handled differently. Do you know what the correct syntax would be to check that? As it looked to be included in a different way with info.block of some sort – StuartM Feb 28 '15 at 19:43
1
<?php if ($params->get('link_category') == 1) : ?>
    <a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($this->item->catslug)); ?>" itemprop="genre" class="btn btn-featured article-viewcat-btn">View all <?php echo $this->item->category_title; ?></a>
<?php endif; ?>

This was what I specifically needed, then on each category I could use the link category to show the button to all on the individual articles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.