Joomla 1.5: $this->countModules returns 1 for Jumi module even when empty - joomla

Working on a site in Joomla 1.5! Typically when testing if a module position is empty in Joomla! I'd do something like this:
<?php if ($this->countModules('position')): ?>
BEFORE
<jdoc:include type="modules" name="position" style="xhtml" />
AFTER
<?php endif; ?>
But in my case I have a jumi module that references external source of code.
In some situations it will be blank, which in that case, I don't want the BEFORE and AFTER bits showing either. But whenever I try running the above code, the before and after sections show up, because
$this->countModules() returns 1 instead of 0.
I have "Hide if empty" set to "Yes" for the module, but that doesn't seem to help.
I've even tried setting a return false; on the external source code but that doesn't seem to help either.
Does anybody have any suggestions?

Hide if empty cannot hide the BEFORE and AFTER because it's in the count condition.And BEFORE and AFTER will only hide if no module is enabled for that position. So to hide these you'll have to put this content inside your module.And check the if empty condition.
Let me know if it's not clear.

Related

Processwire Add css class to page

I there a possibility to add a classname to a page?
I can't figure out how to implement such feature or if it already exists.
I'm using Processwire 3.0.42.
Put something like this in your template where the body is:
<body class="<?php echo $page->template->name; ?>">
That will give your page body tag a class equal to page template name.
You can add a page title in the same way.
<body class="<?php echo $page->name; ?>">
Don't be worried about adding a class to every page. The overhead of doing this is negligible.
If you wish to add a different class you would need to add a field to your template and append it to the code above.
As always in ProcessWire, everything is under your control. Alternatives to #ivangretsky's perfectly good answer would include-
Simply include a conditional in your template file. (This doesn't scale well if you need to add other classes to other pages using the same template.)
<?php
$bodyClass = '';
if($page->id == 1021) $bodyClass = 'my-class';
?>
<body class="<?php echo $bodyClass; ?>">
NB Using $page->id is better than $page->name, for example, as the ID doesn't change while the name could.
You could also add a field to the page template definition. Add a field called something like 'Body Class'. Then use the content of that field in your template file.
<body class="<?php echo $page->body-class; ?>">
This will scale better than my other suggestion, and there are options in the ProcessWire backend to hide or partially hide the field during normal use if you don't want users messing with its value.
One 'gotcha' from the CSS spec to be aware of is that CSS identifiers, including class names and IDs cannot start with a digit, so you cannot just use $page->id.
There are lot of options and it depends on your needs and maybe imagination :-).
You can use page name, template name, page id, or maybe combination.
<body class="<?php echo $page->template->name; ?> page-id-<?php echo $page->id; ?>">
// Output
<body class="your-template-name page-id-1234">
This way you can target template, page, or both.
Or, as mentioned by #ivangretsky, you can add custom field to page. And again, you can combine this aproach with template name, etc.
It depends on your needs and what you want to achieve.
Notice:
Using $page->id is better than $page->name, as the ID doesn't change while the name could. #DaveP

How to edit the source code of joomla individual pages

I have a Joomla site, and I want to remove a the footer div from a page without it affecting it on the other pages. Please is there a way I can do it.
You have a couple options - you should be able to set additional CSS on that article to hide the particular footer div for that one individual page without issue.
Additionally you could install a plugin like Sourcerer that allows for PHP coding directly into articles in Joomla! (which comes in REALLY handy!); then you could remove it programmatically as well if necessarily.
Alternatively - you could create a template override for that particular template/page and edit the PHP there to reflect appropriate course of action for that URL/Page.
I tried to list them in order of easiest to most difficult.
It´s not a clean method to hide template-elements by using CSS (display:none). And for your intension you dont´t need a external plugin.
Try a page-option in your template index.php.
First - to get page-options work:
<?php $pageoption1 = JRequest::getVar( 'Itemid', '' ); $pageoption2 = JRequest::getVar( 'page', '' ); $pageoption3 = JRequest::getVar( 'option', '' ); ?>
And further:
<?php if ($pageoption1 == '1') { ?>
This text will be visible only in the page with Menu Item ID 1
<?php } ?>
This works lately in Joomla 2.5.X - for newer version i think it will also work fine.

Changing the position of Joomla 3.2 tags

I have added some tags and linked these to an article. On the front end the tags appear on top (i.e. before) the article text. Instead I would like to display them at the bottom (i.e. after) the article.
I assume I have to make an override of layouts/joomla/content/tags.php
Create a Template Override for the following file:
components/com_content/views/tmpl/default.php
Once done, open this file in your override location and go to line 157 and you will see the following:
<?php if ($params->get('show_tags', 1) && !empty($this->item->tags)) : ?>
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php endif; ?>
Move this section of code somewhere futher down in the file to suit your needs
Hope this helps
This can be easily achieved by simply changing the Position Of Article Info to "Below" in Options Tab in Joomla Menu. The Joomla menu has to be of Type "Article"
No need to create any override.
Hope this helps.
See attached screenshot.

Joomla Change Modules in Sidebar on diffrent Pages

I'm using Joomla 2.5.7 and want to ask, how I can change a bunch of modules in sidebar, when I change to another Page. An example to clarify my question:
I have 3 Links at the navigation bar:
Events
Shop
Blog
and a Homepage as index.html (logical).
Now, I want display in Events the modules "Where to go" and "About Location" in the sidebar.
In Shop I want to display the modules "About Dealer", "Shipping" and "Images" in the sidebar without the modules "Where to go" and "About location".
In Blog I want to display the module "About Author" in sidebar without the modules above (Where to go, about location...).
So, I know I can do this (or similar):
<?php if ($this->countModules('sidebar-a and sidebar-b and sidebar-c')): ?>
<jdoc:include type="modules" name="sidebar-a" />
<jdoc:include type="modules" name="sidebar-b" />
<jdoc:include type="modules" name="sidebar-c" />
<?php endif; ?>
SIDEBAR-A: "Where to go" and "About Location"
SIDEBAR-B: "About Dealer", "Shipping" and "Images"
SIDEBAR-C: "About Author"
But that is not my plan!
I want just the position "sidebar-a" and that the modules getting hidden (like in countModules) if they are not for this page.
I see this method on the granty framework:
<?php /** Begin Main Body **/ ?>
<?php echo $gantry->displayMainbody
'mainbody','sidebar','standard','standard','standard','standard','standard'); ?>
<?php /** End Main Body **/ ?>
You see just simple code, but with other variables.
So very easy in the index.html but this won't work If I do copy and paste ;)(logical)
I don't know how to do it. I do not prefer to get this framework, just for this single sidebar. But there must be a way like this granty framework, but I can't understand the code very well...I'm just an amateur on php. I guess there must be a JavaScript file, which hide and display this diffrent modules.
You can see a live demo here of the single sidebar with lots of modules, which getting hidden and displayed on each page: http://app.ohanah.com/demo-v2/rt/index.php
Have someone an idea how to run this sidebar?
Thanks for reading and helping!
In the Joomla backend, go to the Module Manager, open the module you want to change, and in the bottom left, you can assign the module to specific pages. This should be what you're looking for and it will save you having to hard code it.
You can , for better handling, use the Module Everywhere extension , look for it in JED.
It helps you a lot assigning modules not only to menulinks, but even to articles.

joomla without a component on the main page

On the page I edit modules constitute the main page. Actually there is no need for any component out there.
I can't remove jdoc from the template because other part of the site requires it.
I wonder what is the best solution for the problem: for main page I need one template but for others another.
As far I have worked with joomla internals almost never with back-end so I guess my knowledge lack in this department.
Any hint how to achieve that?
You can do something in your template like:
<?php
$menu = JSite::getMenu();
if ($menu->getActive() != $menu->getDefault()) : ?>
<jdoc:include type="component" />
<?php endif; ?>
Which will disable the component position when on the default [home] page

Resources