Which is the way to show active message with Fabrik

mattsh

Member
Hi!

I plan to use Fabrik to show 'system messages' on several Joomla site but just using one db. And I think the best way is to use a Fabrik list to show the message and administrate the messages.

The difficult part (for me anyway) is to not show the 'system messages' if its not any at the moment, or a message 'No records'. I just want to show a message if it is any.

Any idea how to solve this?

Regards
Matt
 
Assuming you want to display it in a module, you could use one of the extensions that let you have custom PHP in a module (the NoNumber products, or Flexi Custom Code).

You could then use a little custom PHP in the module to see if there are any rows to be displayed, and if not output a minimal "no messages" message, and if there is, output the string for a fabrik content plugin ...

Code:
$myDb = JFactory::getDbo();
$myQuery = JFactory::getQuery(true);
$myQuery->select('count(*) as msg_tot')->from('your_msg_table')->where('active = 1');
$myDb->setQuery($myQuery);
$msg_tot = (int) $myDb->loadResult();
if ($msg_tot > 0) {
   echo "{fabrik view=list id=123}";
}
else {
   echo "no messages";
}

Obviously change the table and field names, etc. That query assumes you have a field called 'active' which is 0 or 1, leave that off if you just want to display all rows and delete them when they are not needed, rather than turning a status on and off.

-- hugh
 
Thanks for the code!

Showing the potential message in a module is my plan, so using a custom module is good idea.

The change to your suggestion is that I need fields for start and stop for publishing and some categories. A bit similar to joomla articles, but I want to be flexible to show (or not show) selected data on maybe 20 sites. In your example I guess its just to add my "filter" fields to the "where" statement.

I'm not a coding expert so I wonder if this code
Code:
echo "no messages";
show a "no messages" or is it handled by the custom module to not show anything at all?

Regards
Matt
 
Depends on the extension you use, I guess. I don't actually know if any of them will skip showing the module if the output is empty.

-- hugh
 
Think I found another way to solve this, looks fine so far. I'm using the class=empty Data Message to hide the Fabrik list with some extra styling if it's no records. And I don't need any extra modules, just the Fabrik list module.

Matt
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top