Display something by Tag Id Joomla 4 - joomla

Does anyone know how to display something by Tag ID in a php file included in a module ?
The code <?php if (($tag->id == 6)) ?> works in content.php by not in a extern php file.
Thanks a lot !

Related

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.

how to change html file with url get id in php

For example I have two html files sample1.html and sample2.html and I want to show them in one php file, like if I entered www.mydomain.com/index.php?show=sample1 will show the sampl1.html and ?show=sample2 will show sample2.html but in only one page
Something like that ?
<? include($_GET['show'].".html"); ?>
It not the a secure answer but I think this is what you want...

How do I manually theme Views in Drupal 7?

I am new to drupal and I am trying to figure out how to theme Views. I currently have a content type called Category with the following fields:Title, Image and Body. I created a view for the above mentioned content type so that I would list view of all the categories I have created.
To custom theme the view I created a folder called views in my theme folder, and created the following view files:
views-view-fields--plugin-categories.tpl.php
views-view--plugin-categories.tpl.php
views-view-unformatted--plugin-categories.tpl.php
This is what I currently have in my first file:
<div class="<?php print $classes; ?>">
<?php if ($rows): ?>
<div class="view-content">
<?php print $rows; ?>
</div>
<?php elseif ($empty): ?>
<div class="view-empty">
<?php print $empty; ?>
</div>
<?php endif; ?>
<?php if ($more): ?>
<?php print $more; ?>
<?php endif; ?>
</div><?php /* class view */ ?>
Instead of $rows, I tired to use print $field['image'] and print $field['body'] but this method does seem to work. Could you kindly advise on how I could theme the three fields, within categories, displayed using view?
You should name your template like this
views-view-fields--<machine-name-of-your-view>.tpl.php
So I'm assuming from the above that your view is called 'plugin-categories'. An easy way to check is to go to edit the view and look at the URL while you're on the edit page. It should have the format /admin/structure/views/view/YOUR-VIEW'S-MACHINE-NAME/edit, so you can get it from there.
Once you're sure it has the right name, clear your cache to make sure Drupal is picking up your new template. You just need the one above, not all three to modify the output of the three fields in question.
Once you've cleared cache, Drupal should be picking up the new template. You didn't mention exactly what isn't working, just that it's not working, so I wanted to cover the naming and caching, just in case. Now, to output particular fields in this view template, call them like this:
$fields['your-field-machine-name']
So $fields['body'] (I think you're missing an 's')
You should have nothing about $rows in this template! If you have anything about $rows, you haven't copied and pasted from the correct views template. Simply output the fields as you want them to appear in your view, in whatever order you want with the syntax above and put in whatever css classes, etc you want.
Let us know if that works!

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

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.

How to get particular page URL in magento

I would like to get a page's URL key in Magento.
For example, I have a CMS page called "What's New" with the identifier (or URL key) "whats_new". Its correct URL is therefore http://mysite.com/whats_new
Currently I use this code to echo its location:
<?php echo Mage::getBaseUrl();?>whats_new
I feel it's bad practice because its identifier (or URL key) is administrable; if its URL key or identifier changes then the link will break. What is the proper way to echo its dynamic URL key? Perhaps something similar to Wordpress's get_permalink('10')?
I think this will do what you want:
<?php echo Mage::helper('cms/page')->getPageUrl( $pageId ) ?>
Replace $pageId with the correct id for the page you are linking to and it should work.
Try this
<?php echo $this->getUrl('whats_new');?>
If you need to add url key dynamically then
<?php echo $this->getUrl($yourDynamicVariable);?>
of course you must implement the features that you need to fill the variable if url key is changed
You shoud use <?php echo Mage::getUrl('page-url.html); ?>
In CMS Page
{{store _direct="url_key"}}
If you want in .phtml file then
<?php echo Mage::helper('cms/page')->getPageUrl('url_key') ?>
Mage::getUrl(null, array('_direct' => $page->getIdentifier()));
It is also possible to retrieve the CMS page URL using the page identifier like,
<?php echo Mage::helper('cms/page')->getPageUrl('cms_page_identifier') ?>
You shoud use
{{store direct_url="whats_new/"}}
<?php echo $this->getUrl('whats_new');?>

Resources