- Posts: 40
COMMUNITY FORUM
Toggle featured state frontend
- John-Eilif Eliassen
-
Topic Author
- Offline
- Senior Member
Less
More
8 years 11 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.
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
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
8 years 11 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
-
- Offline
- Elite Member
Less
More
- Posts: 169
8 years 11 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
In order to create an else statement you can do something like the following one
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;?>
Please Log in or Create an account to join the conversation.
- John-Eilif Eliassen
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
8 years 11 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
-
- Offline
- Elite Member
Less
More
- Posts: 169
8 years 11 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.
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.
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.
Please Log in or Create an account to join the conversation.
- John-Eilif Eliassen
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
8 years 11 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
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 40
8 years 11 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?
Do you know if this is possible?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 11 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.
Please Log in or Create an account to join the conversation.