if com_content is not empty show sidebar

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
jlearner1986
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Sun Jun 22, 2014 11:24 am

if com_content is not empty show sidebar

Post by jlearner1986 » Mon Jul 28, 2014 8:15 am

hello there
how to know if com_content is active on a page...
I want my right-sidebar only in pages with com_content so I need a php condition which I have this:

<?php
$doc =& JFactory::getDocument();
$data = $doc->getBuffer('component',’com_content’);
$sPattern = '/\s*/m';
$sReplace = '';
$ndata = preg_replace( $sPattern, $sReplace, $data );
?>

<?php if(!empty($ndata)) { ?>
--------------------right-sidebar---------------
<?php } ?>

but it's not working :(
any idea what's wrong???
maybe the whole thing is wrong, so any idea how to do that??
is there an specific parameter for com_content that can be used in this case??
what the heck do I do!!??? I need this and apparently I'm not smart enough :eek:
your valuable consideration is highly appreciated

FlashRebel

Re: if com_content is not empty show sidebar

Post by FlashRebel » Mon Jul 28, 2014 10:03 am

Why do it like that ? It is much simplier just assign modules on right side bar for menus and for menus you dont like to show something, u will not assign these module and it will stay empty.

jlearner1986
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Sun Jun 22, 2014 11:24 am

Re: if com_content is not empty show sidebar

Post by jlearner1986 » Mon Jul 28, 2014 10:45 am

well it's not like that, I have a general layout with one left-side bar and I do assign modules to where ever I need, but when someone opens an article to read a single article... now I want my right-sidebar !! so for example I'm under a menu with the name "product" there is a link under product... when you click on the link the article will open under the product menu, which means I don't have any option for right side-bar under the product, but if I could use the condition ... once the single article is open the right-sidebar will be shown.... and of course sorry for bad English.


Locked

Return to “General Questions/New to Joomla! 3.x”