Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Show module when a particular article is set to Published

Show module when a particular article is set to Published

Is there a way to display a module ONLY if a specific article is published?

My client is a school district.  There is a module that displays a "School Closed" banner if the Superintendent closes school for a day.  In the past, the user had to access the back-end of the site, find the module, and publish it for display in order to show the notice.  I would like them to be able to do this from the front end.  My thought was having an article that the Superintendent can edit, which does not display anywhere on the site.  If the Superintendent wants to display the "School Closed" module, all he has to do is set this particular article to Published and the module will display.  Is this possible, or do you have a better solution?

Thanks!!

momentis
Web Developer
Beginner Modder
ranks
useravatar
Offline
12 Posts
User info in posts
Administrator has disabled public posting

Re: Show module when a particular article is set to Published

Yes, you could do that. It's not the most elegant of solutions but as you say, it allows a user to do it from the front end of the site.

Something I have toyed with in the past but never actually tried out for real, is to trigger actions with e-mails. Here's how it could work:

1 - on cPanel on your server, you would have to set up a mail forwarder to "Pipe to a Program" (shell script) rather than redirected to another address. You would send an e-mail to that address in order to trigger actions.

2 - the shell script would create or delete a file in response to the message. e.g. if the email subject was PUBLISH then it would create a blank file in a specified location, or if it was UNPUBLISH then it would delete that file.

3 - the MetaMod then looks for the existence of that file, and publishes or unpublishes a module in response to that.

Ok, so if you know how to set all that up then you just tell your administrator to send appropriate e-mails to that address in order to control the server.


If you want to use your original idea, then you could do this in the MetaMod:

$query = "sel" . "ect state from #_" . "_content where id = XXX";
$db->setQuery($query);
$result = $db->loadResult();
if ($result == 1) return YYY;


Replace XXX with the id of the article you want to check on, and YYY with the module id to return.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1666
Total Polls:
6
Total Posts:
5909
Dormant:
User Info:
 
Total Users:
10095
Newest User:
johnson58
Members Online:
0
Guests Online:
102

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked