Saturday, 23 November 2013

Joomla Tricks(Not For sale)

Call static image and stylesheet

<a href="#"><img title="facebook" alt="facebook" src="<?php echo JURI::root();?>/templates/alokjha/images/facebook-32x32.png" /></a>
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/css/template.css" type="text/css" />

Call page title

<?php $mydoc =& JFactory::getDocument();$mytitle = $mydoc->getTitle();echo $mytitle;
 ?>

Call search form

<form method="post" action="/joomla/index.php" role="search">
    <div class="search">
        <label for="mod-search-searchword">Search...</label><input type="text" onfocus="if (this.value=='Search...') this.value='';" onblur="if (this.value=='') this.value='Search...';" value="Search..." size="20" class="txt_field" maxlength="20" id="mod-search-searchword" name="searchword">    <input type="hidden" value="search" name="task">
    <input type="hidden" value="com_search" name="option">
    <input type="hidden" value="472" name="Itemid">
    </div>
</form>

 <div id="fontsize"></div>
                                        <h3 class="unseen"><?php echo JText::_('TPL_BEEZ2_SEARCH'); ?></h3>
                                        <jdoc:include type="modules" name="position-0" />

Call Home page

<?php JURI::root(); ?>

Call front page in joomla

<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
   
        echo 'This is the front page';
}
?>

Is this Front page?

Basic code, as shown at Joomla help, is
<?php $menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';
} ?>

For multi-language sites

Show different content based on selected language
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault( 'en-GB' )) {
echo 'This is the front page';
}
elseif ($menu->getActive() == $menu->getDefault( 'fr-FR' )) {
echo 'Il sagit de la premi?re page';
}
?>

<?php $menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
$frontpage="yes";
} ?>

to beginning of template’s index.php file

Every time, you want to check if user is on frontpage, use
<?php if ($frontpage) {//do something} ?>

Show text on
<?php if ($frontpage) {echo This is frontpage} ?>

Show module
<?php if ($frontpage) {echo '<jdoc:include type="modules" name="modulename" style="xhtml"/>';} ?>

Hide module
<?php if (!$frontpage) {echo '<jdoc:include type="modules" name="modulename" style="xhtml"/>'} ?>

only difference from previous example is little exclamation mark in if statement

Show long HTML code
<?php if ($frontpage): ?>
<div id="box1"><div>Content</div></div>
<div><div>Content </div></div>
<div id="box2">There can be anything</div>
<?php  endif; ?>

Add CSS class
<body<?php if (JRequest::getCmd('view') == frontpage)  {echo 'class="classname" '} ?>

Then of course define body.classname {} in your CSS file
Include Javascript
Paste this between head tags
<?php if ($frontpage") {echo '<script type="text/javascript" src="pathtoscripts/jquery.js"></script>';} ?>

joomla-banners

http://www.siteground.com/tutorials/joomla/joomla-banners.htm

Open Menu in title

<div id="Modulecontainer"> </div>
<p class="button btn-success"><strong><a class="modal" href="login-form" rel="{handler: 'iframe', size: {x: 640, y: 480}}">Login / </a> <a class="modal" href="registration-form" rel="{handler: 'iframe', size: {x: 640, y: 910}}">Registration</a></strong></p>

3 comments:

  1. Nice Posts..Interesting and useful information!

    ReplyDelete
    Replies
    1. Thanks ..
      I am requesting you all to post informatics about PHP,
      I will be always thankful to you..

      Delete
  2. What a nice code is given in this blog

    ReplyDelete

Thank you for you feedback