Keyword

Toggle featured state frontend

  • John-Eilif Eliassen
  • John-Eilif Eliassen's Avatar Topic Author
  • Offline
  • Senior Member
More
7 years 10 months ago #154845 by John-Eilif Eliassen
Toggle featured state frontend was created by John-Eilif Eliassen
Hi.

I have a list of articles from a spesific category in one page. It should only show one line of info. On the frontpage, I want to show only the latest featured article, which i have set up perfectly from the content module. But i would like to have the option, in the article list, to toggle an article to be featured (show on frontpage) or not. It is just one line of info that will change from time to time, and if no articles are featured, it will say something premade.

Appreciate any help on this.

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

  • John-Eilif Eliassen
  • John-Eilif Eliassen's Avatar Topic Author
  • Offline
  • Senior Member
More
7 years 10 months ago #154846 by John-Eilif Eliassen
Replied by John-Eilif Eliassen on topic Toggle featured state frontend
I am also wondering about how i may make an else statement in the content module so that if there are no articles, it displays an optional message..?

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

  • JoomlaWorks Support Team
  • JoomlaWorks Support Team's Avatar
  • Offline
  • Elite Member
More
7 years 10 months ago #154854 by JoomlaWorks Support Team
Replied by JoomlaWorks Support Team on topic Toggle featured state frontend
Hi,

There is already an if statement at the default.php template file that checks if there are any items before passing the data to the foreach loop.
Locate the
<?php if(count($items)): ?>

In order to create an else statement you can do something like the following one
<?php if(count($items)): ?>
.....
<?php else:?>
<div>[NO ITEMS TO DISPLAY TEXT]</div>
<?php endif;?>

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

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

  • John-Eilif Eliassen
  • John-Eilif Eliassen's Avatar Topic Author
  • Offline
  • Senior Member
More
7 years 10 months ago #154916 by John-Eilif Eliassen
Replied by John-Eilif Eliassen on topic Toggle featured state frontend
Hi, I've tried that if /else statement but it does not work in the content module when only featured items shall display..... when no items in the selected category is featured, the module is hidden even if i have an else statement.

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

  • JoomlaWorks Support Team
  • JoomlaWorks Support Team's Avatar
  • Offline
  • Elite Member
More
7 years 10 months ago #154922 by JoomlaWorks Support Team
Replied by JoomlaWorks Support Team on topic Toggle featured state frontend
You are correct. Check the files modules/mod_k2_content at Line 53-56. If the $items variable has no data then the template file of the module is not included.
if (count($items))
{
    require (JModuleHelper::getLayoutPath('mod_k2_content', $getTemplate.DS.'default'));
}

You can add an else statement there. Beware though that you are hacking the core by doing this and you may have issues on future updates.

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

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

  • John-Eilif Eliassen
  • John-Eilif Eliassen's Avatar Topic Author
  • Offline
  • Senior Member
More
7 years 10 months ago #154925 by John-Eilif Eliassen
Replied by John-Eilif Eliassen on topic Toggle featured state frontend
Thanks for the reply Teo, I tried this and it worked perfectly.
if (count($items))
{
    require (JModuleHelper::getLayoutPath('mod_k2_content', $getTemplate.DS.'default'));
}
else
{
	echo '<h2>All systems up and running.</h2>';
}

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

  • John-Eilif Eliassen
  • John-Eilif Eliassen's Avatar Topic Author
  • Offline
  • Senior Member
More
7 years 10 months ago #154926 by John-Eilif Eliassen
Replied by John-Eilif Eliassen on topic Toggle featured state frontend
Now i just need some help adding a quicktoggle button for admins on the frontend (category view) to switch an article between being featured or not...

Do you know if this is possible?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 10 months ago #154939 by Krikor Boghossian
Replied by Krikor Boghossian on topic Toggle featured state frontend
Unfortunately you will have to manually edit each item in order to change the featured flag.

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

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


Powered by Kunena Forum