The Joomla! Forum ™





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 111 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Sun May 11, 2008 9:19 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Feb 27, 2006 7:49 pm
Posts: 14
can someone post this for joomla 1.5.3 that would be great


Top
 Profile  
 
PostPosted: Mon May 19, 2008 7:29 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed Nov 02, 2005 8:54 am
Posts: 199
Location: London and Cork
This a great contribution, and I agree it should be part of core. Its now part of my preferred core.

BUT, I have an issue with the following part. The params in the XML file throw an error and I think its to do with the > comparitor used.

Quote:
<option value=">19">Author and above</option>
<option value=">20">Editor and above</option>
<option value=">21">Publisher and above</option>
<option value=">23">Manager and above</option>
<option value=">24">Administrator and above</option>
<option value="<19">Author and below</option>
<option value="<20">Editor and below</option>
<option value="<21">Publisher and below</option>
<option value="<23">Manager and below</option>
<option value="<24">Administrator and below</option>



I think its because the > character (in >19 etc..) is used in the XML to define the fields, so it is prematurely ending the field definition and failing to read the XML file correctly.

I don't really know XML so does anyone know if is there any way I can 'escape' the > character to let the XML work. Or do I have to try and use an alternate character and hack the hack ??

I am using 1.0.15 and am not sure if this is a new error for this version only.


Top
 Profile  
 
PostPosted: Mon May 19, 2008 4:53 pm 
Joomla! Guru
Joomla! Guru

Joined: Thu Aug 18, 2005 10:51 pm
Posts: 697
Location: Austria
Should be possible to use &gt; for > and &gt; for < (not tested yet, but should work)

_________________
http://www.joomx.com - custom extensions and development
http://www.joomlasupportdesk.com - support, migration, training and consulting
Member of the German Joomla Translation Team


Top
 Profile  
 
PostPosted: Sat May 24, 2008 5:47 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed Nov 02, 2005 8:54 am
Posts: 199
Location: London and Cork
I really struggled with this. For whatever reason with my setup and running 1.0.15 the XML would not parse the > and < symbols inside the params. I tried &gt; and &lt; as was kindly suggested, no joy. I tried putting the < and > encpasulated inside CDATA - nada.

Then I looked back at the hack inside frontend.php and realised that the > and < are not used as logical comparitors by the hack, they are just used as a text string, so they could be any text. In my case "L" (less than) and "M" (more than).

So I got it working and I am delighted. This is so cool ! :D

I have made tiny changes, but made all the difference to me. I hope it helps someone else.

My variant of the 2nd frontent.php hacks looks like this (the first hack is unchanged) ...

Quote:
// HACK: to hide modules for certain groups of logged in users
$myRealGid = intval($acl->get_group_id($my->usertype));
// --- end HACK ---
foreach ($modules as $module) {
// HACK: added code to check if module should be shown when a user is logged in and is in a particular group
$params = new mosParameters( $module->params );
if (!$params->get('show_registered', 1) && $my->id) {
// check the gid if param set
if ($params->get('hide_for_gid', 0) != '0') {
if (strlen($params->get('hide_for_gid')) > 2) {
// if we're looking at ranges, extract the comparator and the gid to compare
$comparator = substr($params->get('hide_for_gid'), 0, 1);
$hideGid = intval(substr($params->get('hide_for_gid'), 1));

if (($comparator == "M" && $myRealGid >= $hideGid) || ($comparator == "L" && $myRealGid <= $hideGid)) {
continue;
}

} elseif (intval($params->get('hide_for_gid')) == $myRealGid) {
// if the user's gid is equal to the parameter, hide the module
continue;
}
} else {
// simply continue the loop without outputting this module
continue;
}
}
// --- end HACK ---
$GLOBALS['_MOS_MODULES'][$module->position][] = $module;
}


My variant of the Module XML is like this ...
Quote:
<param name="show_registered" type="radio" default="1" label="Show Menu When Logged In" description="Show the menu also when a registered user is logged in">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="hide_for_gid" type="list" default="0" label="Hide Module for this User Type Only" description="If above is set to 'No', you can specify which registered user type you want to hide this module for. Default hides the module for any logged in user.">
<option value="0">Default</option>
<option value="18">Registered</option>
<option value="19">Author</option>
<option value="20">Editor</option>
<option value="21">Publisher</option>
<option value="23">Manager</option>
<option value="24">Administrator</option>
<option value="25">Super Administrator</option>
<option value="M19">Author and above</option>
<option value="M20">Editor and above</option>
<option value="M21">Publisher and above</option>
<option value="M23">Manager and above</option>
<option value="M24">Administrator and above</option>
<option value="L19">Author and below</option>
<option value="L20">Editor and below</option>
<option value="L21">Publisher and below</option>
<option value="L23">Manager and below</option>
<option value="L24">Administrator and below</option>
</param>


Top
 Profile  
 
PostPosted: Sat Jun 14, 2008 9:02 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 03, 2008 8:37 am
Posts: 17
Ok so I decided I really needed this too so I got it to work. But I'm no expert programmer either so if somebody knows a better way please let us know but here goes what worked for me.

Added this after the last parameter of the XML file for whatever module you want to hide for example the login module which is located here (modules\mod_login\mod_login.xml):

<param name="show_registered" type="radio" default="1" label="Show Menu When Logged In" description="Show the menu also when a registered user is logged in">
<option value="0">No</option>
<option value="1">Yes</option>
</param>


Then replace the function render( $position, $params = array(), $content = null ) in \libraries\joomla\document\html\renderer\modules.php with the following


function render( $position, $params = array(), $content = null )
{
$renderer =& $this->_doc->loadRenderer('module');

$contents = '';
foreach (JModuleHelper::getModules($position) as $mod) {
// HACK: added code to check if module should be shown when a user is logged in
$pattern = '/show_registered=0/';
$match = preg_match($pattern, $mod->params);
$userId = $_SESSION["__default"]['user']->id;
if ($match && $userId) {
// simply continue the loop without outputting this module
continue;
}
// --- end HACK ---
$contents .= $renderer->render($mod, $params, $content);
}
return $contents;
}


UPDATED: I noticed that modules that use the module count need an additional hack to the file:
\libraries\joomla\application\module\helper.php

after the line $modules = array();
and before the line $db->setQuery( $query );

//HACK check in logged in then run query to exclude the correct modules
if($userId = $_SESSION["__default"]['user']->id >0){
$wheremenu = isset( $Itemid ) ? ' AND ( mm.menuid = '. (int) $Itemid .' OR mm.menuid = 0 )' : '';
$query = 'SELECT id, title, module, position, content, showtitle, control, params'
. ' FROM #__modules AS m'
. ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'
. ' WHERE m.published = 1'
. ' AND m.access <= '. (int)$aid
. ' AND m.client_id = '. (int)$mainframe->getClientId()
. " AND m.id NOT IN (SELECT id FROM #__modules WHERE params LIKE '%show_registered=0%')"
. $wheremenu
. ' ORDER BY position, ordering';
}else{
$wheremenu = isset( $Itemid ) ? ' AND ( mm.menuid = '. (int) $Itemid .' OR mm.menuid = 0 )' : '';
$query = 'SELECT id, title, module, position, content, showtitle, control, params'
. ' FROM #__modules AS m'
. ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'
. ' WHERE m.published = 1'
. ' AND m.access <= '. (int)$aid
. ' AND m.client_id = '. (int)$mainframe->getClientId()
. $wheremenu
. ' ORDER BY position, ordering';
}
//HACK
/*ORIGINAL CODE
$wheremenu = isset( $Itemid ) ? ' AND ( mm.menuid = '. (int) $Itemid .' OR mm.menuid = 0 )' : '';
$query = 'SELECT id, title, module, position, content, showtitle, control, params'
. ' FROM #__modules AS m'
. ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'
. ' WHERE m.published = 1'
. ' AND m.access <= '. (int)$aid
. ' AND m.client_id = '. (int)$mainframe->getClientId()
. $wheremenu
. ' ORDER BY position, ordering';
ORIGINAL CODE*/


Top
 Profile  
 
PostPosted: Wed Jul 02, 2008 10:53 am 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Wed Nov 07, 2007 7:58 pm
Posts: 270
Location: Auckland, New Zealand
Do you have a 1.5 hack for this?

_________________
Andre
==============================
John 3 vs 16-17; Romans 10 vs 9


Top
 Profile  
 
PostPosted: Wed Jul 02, 2008 3:19 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 03, 2008 8:37 am
Posts: 17
That hack I posted is for 1.5


Top
 Profile  
 
PostPosted: Wed Jul 02, 2008 9:19 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Wed Nov 07, 2007 7:58 pm
Posts: 270
Location: Auckland, New Zealand
That will teach me for trying to understand something late at night :-)

:-[

Great Hack.. works great!

_________________
Andre
==============================
John 3 vs 16-17; Romans 10 vs 9


Top
 Profile  
 
PostPosted: Fri Jul 11, 2008 9:40 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Mon Oct 08, 2007 9:13 am
Posts: 148
I think I've found the solution to most of the problems I experience. I can search for hours and hours and try to resolve the problem. As soon as I post a question I often find the solution within minutes. Anyway, that was the case here. I did try to resolve it on my own for some time.

The solution was later in this thread. It was written that there was an error in the code. I thought I selected the code form the correct post. I didn't. Once I had the correct post to copy and paste from it was fixed.

So disregard the following:

I really need this function and would love it if someone could tell me what I need to fix. I did the changes as outlined and get the following error:

Fatal error: Call to a member function on a non-object in /includes/frontend.php on line 96

I believe it is related to this code, but I'm not sure if I counted the code correctly.

Code:
// set up some global variables for use by frontend

components
   global $mainframe, $database, $my , $acl;
   global $task, $Itemid, $id, $option, $gid;

   include( $mainframe->getCfg( 'absolute_path'

)."/components/com_$name/$name.php" );
}


Can someone point out a fix? Thanks!

_________________
Leisa Watkins
http://www.WealthWisdomAndSuccess.com


Top
 Profile  
 
PostPosted: Fri Jul 11, 2008 10:02 am 
Joomla! Guru
Joomla! Guru

Joined: Thu Aug 18, 2005 10:51 pm
Posts: 697
Location: Austria
As far i can see, the error is not inside the lines you provided.
Please post more or count right and post the correct line(s)

_________________
http://www.joomx.com - custom extensions and development
http://www.joomlasupportdesk.com - support, migration, training and consulting
Member of the German Joomla Translation Team


Top
 Profile  
 
PostPosted: Fri Jul 11, 2008 3:38 pm 
Joomla! Intern
Joomla! Intern

Joined: Wed Sep 26, 2007 6:11 pm
Posts: 50
Location: Indianapolis
This is basic, but in case it helps someone, for custom modules they must edit the custom.xml file in the modules folder.

_________________
Only exact URLs allowed in signature. Please read Forum Rules: viewtopic.php?f=8&t=65


Top
 Profile  
 
PostPosted: Fri Jul 11, 2008 4:15 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Mon Oct 08, 2007 9:13 am
Posts: 148
piersol wrote:
This is basic, but in case it helps someone, for custom modules they must edit the custom.xml file in the modules folder.


Would you mind explaining what the function is of the custom.xml file?
Is it a basic module that one would use as a starting point for creating their own modules?
If we are editing an existing module we don't need to do anything with the custom.xml module do we?

Thanks for helping me to learn more about how Joomla works.

Leisa

_________________
Leisa Watkins
http://www.WealthWisdomAndSuccess.com


Top
 Profile  
 
PostPosted: Fri Jul 11, 2008 4:49 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Mon Oct 08, 2007 9:13 am
Posts: 148
I believe I've modified all the files as outlined. I edited the frontend.php and am not getting an error messages. Then I edited the module and the parameters to show the module when logged in or not to show it shows in the module parameter section. However when I set it to not show when the user is logged in it still shows up.

This is the code for the module:

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<mosinstall type="module">
   <name>Jumi</name>
   <author>Martin Hajek</author>
   <creationDate>March 2008</creationDate>
   <copyright>(c) 2006 - 2008 Martin Hajek. All rights reserved.</copyright>
   <license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
   <authorEmail>admin@vedeme.cz</authorEmail>
   <authorUrl>jumi.vedeme.cz</authorUrl>
   <version>1.2.0</version>
   <description><![CDATA[
   Jumi module for Joomla! and Mambo includes into a module position any file.<br />In an addition it can pass into the included *.php file any number of argument values.<br />There is also a compatible Jumi plugin that includes the same files into Joomla! articles.<br />Jumi manuals, demo, tips and tricks and snippets can be found at <a href="http://jumi.vedeme.cz" target="_blank">jumi.vedeme.cz</a>
   ]]></description>
   <files>
      <filename module="mod_jumi">mod_jumi.php</filename>
      <filename>jumi_demo.php</filename>
   </files>
   <params>
      <param name="moduleclass_sfx" type="text" default="" label="Module Class Suffix" description="A suffix to be applied to the css class of the module (table.moduletable), this allows individual module styling" />


      <param name="show_registered" type="radio" default="1" label="Show Module When Logged In" description="Show the menu also when a registered user is logged in">
         <option value="0">No</option>
         <option value="1">Yes</option>
      </param>
      <param name="default_absolute_path" type="text" size ="97" default="" label="Default Absolute Path" description="Optional Default Absolute Path to the included file. If left blank then it is identical to Joomla! root directory. No slash at the end." />
      <param name="file_pathname" type="text" size ="97" default="modules/jumi_demo.php" label="File Pathname" description="The pathname of the file to be included. The pathname is relative with respect to Default Absolute Path." />
      <param name="php_args" type="textarea" default="[first][second] notice you can put anything out of the brackets [and third]" label="Argument Values" description="Any number of values to be passed into the included php file. Each value must be contained in [ ] brackets. Everything outside the brackets is ignored. Argument values can be referrenced by $jumi[] array in an included php file." cols="70" rows="7" />
      <param name="notepad" type="textarea" default="Put your notes here ..." label="Notepad" description="Your notes, reminders, etc." cols="70" rows="7" />   
   </params>
</mosinstall>



This is the code for the frontend.php file:

Code:
<?php
/**
* @version $Id: frontend.php 5930 2006-12-06 00:49:07Z friesengeist $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

defined( '_VALID_MOS' ) or die( 'Restricted access' );
/**
* Displays the capture output of the main element
*/
function mosMainBody() {
   global $mosConfig_live_site;
   // message passed via the url
   $mosmsg = stripslashes( strval( mosGetParam( $_REQUEST, 'mosmsg', '' ) ) );

   $popMessages = false;

   // Browser Check
   $browserCheck = 0;
   if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && isset( $_SERVER['HTTP_REFERER'] ) && strpos($_SERVER['HTTP_REFERER'], $mosConfig_live_site) !== false ) {
      $browserCheck = 1;
   }

   // Session Check
   $sessionCheck = 0;
   // Session Cookie `name`
   $sessionCookieName    = mosMainFrame::sessionCookieName();
   // Get Session Cookie `value`
   $sessioncookie       = mosGetParam( $_COOKIE, $sessionCookieName, null );
   if ( (strlen($sessioncookie) == 32 || $sessioncookie == '-') ) {
      $sessionCheck = 1;
   }

   // limit mosmsg to 150 characters
   if ( strlen( $mosmsg ) > 150 ) {
      $mosmsg = substr( $mosmsg, 0, 150 );
   }

   // mosmsg outputed within html
   if ($mosmsg && !$popMessages && $browserCheck && $sessionCheck) {
      echo "\n<div class=\"message\">$mosmsg</div>";
   }

   echo $GLOBALS['_MOS_OPTION']['buffer'];

   // mosmsg outputed in JS Popup
   if ($mosmsg && $popMessages && $browserCheck && $sessionCheck) {
      echo "\n<script language=\"javascript\">alert('" . addslashes( $mosmsg ) . "');</script>";
   }
}
/**
* Utility functions and classes
*/
function mosLoadComponent( $name ) {
   // set up some global variables for use by frontend components
   global $mainframe, $database, $my;
   global $task, $Itemid, $id, $option, $gid;

   include( $mainframe->getCfg( 'absolute_path' )."/components/com_$name/$name.php" );
}
/**
* Cache some modules information
* @return array
*/
function &initModules() {
   global $database, $my, $Itemid;

   if (!isset( $GLOBALS['_MOS_MODULES'] )) {
      $Itemid       = intval($Itemid);
      $check_Itemid    = '';
      if ($Itemid) {
         $check_Itemid = "OR mm.menuid = " . (int) $Itemid;
      }

      $query = "SELECT id, title, module, position, content, showtitle, params"
      . "\n FROM #__modules AS m"
      . "\n INNER JOIN #__modules_menu AS mm ON mm.moduleid = m.id"
      . "\n WHERE m.published = 1"
      . "\n AND m.access <= ". (int) $my->gid
      . "\n AND m.client_id != 1"
      . "\n AND ( mm.menuid = 0 $check_Itemid )"
      . "\n ORDER BY ordering";

      $database->setQuery( $query );
      $modules = $database->loadObjectList();

       foreach ($modules as $module) {
                       // HACK: added code to check if module should be shown when a user is logged in
$params = new mosParameters( $module->params );
if (!$params->get('show_registered', 1) && $my->id) {
// simply continue the loop without outputting this module
continue;
}
// --- end HACK ---

      foreach ($modules as $module) {
         // HACK: added code to check if module should be shown when a user is logged in and is in a particular group
         $params = new mosParameters( $module->params );
         if (!$params->get('show_registered', 1) && $my->id) {
            // check the gid if param set
            if ($params->get('hide_for_gid', 0) != '0') {
               if (strlen($params->get('hide_for_gid')) > 2) {
                  // if we're looking at ranges, extract the comparator and the gid to compare
                  $comparator = substr($params->get('hide_for_gid'), 0, 1);
                  $hideGid = intval(substr($params->get('hide_for_gid'), 1));

                  if (($comparator == ">" && $myRealGid >= $hideGid) || ($comparator == "<" && $myRealGid <= $hideGid)) {
                     continue;
                  }

               } elseif (intval($params->get('hide_for_gid')) == $myRealGid) {
                  // if the user's gid is equal to the parameter, hide the module
                  continue;
               }
            } else {
               // simply continue the loop without outputting this module
               continue;
            }
         }
         // --- end HACK ---
         $GLOBALS['_MOS_MODULES'][$module->position][] = $module;
      }


                        $GLOBALS['_MOS_MODULES'][$module->position][] = $module;
                }     
   }
   return $GLOBALS['_MOS_MODULES'];
}
/**
* @param string THe template position
*/
function mosCountModules( $position='left' ) {
   global $database, $my, $Itemid, $acl;

   $tp = intval( mosGetParam( $_GET, 'tp', 0 ) );
   if ($tp) {
      return 1;
   }

   $modules =& initModules();
   if (isset( $GLOBALS['_MOS_MODULES'][$position] )) {
      return count( $GLOBALS['_MOS_MODULES'][$position] );
   } else {
      return 0;
   }
}
/**
* @param string The position
* @param int The style.  0=normal, 1=horiz, -1=no wrapper
*/
function mosLoadModules( $position='left', $style=0 ) {
   global $mosConfig_gzip, $mosConfig_absolute_path, $database, $my, $Itemid, $mosConfig_caching;

   $tp = intval( mosGetParam( $_GET, 'tp', 0 ) );
   if ($tp) {
      echo '<div style="height:50px;background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">';
      echo $position;
      echo '</div>';
      return;
   }
   $style = intval( $style );
   $cache =& mosCache::getCache( 'com_content' );

   require_once( $mosConfig_absolute_path . '/includes/frontend.html.php' );

   $allModules =& initModules();
   if (isset( $GLOBALS['_MOS_MODULES'][$position] )) {
      $modules = $GLOBALS['_MOS_MODULES'][$position];
   } else {
      $modules = array();
   }

   if (count( $modules ) < 1) {
      $style = 0;
   }
   if ($style == 1) {
      echo "<table cellspacing=\"1\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
      echo "<tr>\n";
   }
   $prepend = ($style == 1) ? "<td valign=\"top\">\n" : '';
   $postpend = ($style == 1) ? "</td>\n" : '';

   $count = 1;
   foreach ($modules as $module) {
      $params = new mosParameters( $module->params );

      echo $prepend;

      if ((substr("$module->module",0,4))=='mod_') {
      // normal modules
         if ($params->get('cache') == 1 && $mosConfig_caching == 1) {
         // module caching
            $cache->call('modules_html::module2', $module, $params, $Itemid, $style, $my->gid  );
         } else {
            modules_html::module2( $module, $params, $Itemid, $style, $count );
         }
      } else {
      // custom or new modules
         if ($params->get('cache') == 1 && $mosConfig_caching == 1) {
         // module caching
            $cache->call('modules_html::module', $module, $params, $Itemid, $style, 0, $my->gid );
         } else {
            modules_html::module( $module, $params, $Itemid, $style );
         }
      }

      echo $postpend;

      $count++;
   }
   if ($style == 1) {
      echo "</tr>\n</table>\n";
   }
}
/**
* Assembles head tags
*/
function mosShowHead() {
   global $database, $option, $my, $mainframe, $_VERSION, $task, $id;
   global $mosConfig_MetaDesc, $mosConfig_MetaKeys, $mosConfig_live_site, $mosConfig_sef, $mosConfig_absolute_path, $mosConfig_sitename, $mosConfig_favicon;

   $mainframe->appendMetaTag( 'description', $mosConfig_MetaDesc );
   $mainframe->appendMetaTag( 'keywords', $mosConfig_MetaKeys );
   $mainframe->addMetaTag( 'Generator', $_VERSION->PRODUCT . ' - ' . $_VERSION->COPYRIGHT);
   $mainframe->addMetaTag( 'robots', 'index, follow' );

   // cache activation
   if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
      $cache =& mosCache::getCache('com_content');
      echo $cache->call('mainframe->getHead', @$_SERVER['QUERY_STRING'], $id);
   } else {
      echo $mainframe->getHead();
   }

   if ( isset($mosConfig_sef) && $mosConfig_sef ) {
      echo "<base href=\"$mosConfig_live_site/\" />\r\n";
   }

   if ($my->id || $mainframe->get( 'joomlaJavascript' )) {
      ?>
      <script src="<?php echo $mosConfig_live_site;?>/includes/js/joomla.javascript.js" type="text/javascript"></script>
      <?php
   }

   $row = new mosComponent( $database );
   $query = "SELECT a.*"
   . "\n FROM #__components AS a"
   . "\n WHERE ( a.admin_menu_link = 'option=com_syndicate' OR a.admin_menu_link = 'option=com_syndicate&hidemainmenu=1' )"
   . "\n AND a.option = 'com_syndicate'"
   ;
   $database->setQuery( $query );
   $database->loadObject( $row );

   // get params definitions
   $syndicateParams = new mosParameters( $row->params, $mainframe->getPath( 'com_xml', $row->option ), 'component' );

   // needed to reduce query
   $GLOBALS['syndicateParams'] = $syndicateParams;

   $live_bookmark = $syndicateParams->get( 'live_bookmark', 0 );

   // and to allow disabling/enabling of selected feed types
   switch ( $live_bookmark ) {
      case 'RSS0.91':
         if ( !$syndicateParams->get( 'rss091', 1 ) ) {
            $live_bookmark = 0;
         }
         break;

      case 'RSS1.0':
         if ( !$syndicateParams->get( 'rss10', 1 ) ) {
            $live_bookmark = 0;
         }
         break;

      case 'RSS2.0':
         if ( !$syndicateParams->get( 'rss20', 1 ) ) {
            $live_bookmark = 0;
         }
         break;

      case 'ATOM0.3':
         if ( !$syndicateParams->get( 'atom03', 1 ) ) {
            $live_bookmark = 0;
         }
         break;
   }

   // support for Live Bookmarks ability for site syndication
   if ($live_bookmark) {
      $show = 1;

      $link_file    = $mosConfig_live_site . '/index2.php?option=com_rss&feed='. $live_bookmark .'&no_html=1';

      // xhtml check
      $link_file = ampReplace( $link_file );

      // security chcek
      $check = $syndicateParams->def( 'check', 1 );
      if($check) {
         // test if rssfeed module is published
         // if not disable access
         $query = "SELECT m.id"
         . "\n FROM #__modules AS m"
         . "\n WHERE m.module = 'mod_rssfeed'"
         . "\n AND m.published = 1"
         ;
         $database->setQuery( $query );
         $check = $database->loadResultArray();
         if(empty($check)) {
            $show = 0;
         }
      }
      // outputs link tag for page
      if ($show) {
         // test if security check is enbled
         ?>
         <link rel="alternate" type="application/rss+xml" title="<?php echo $mosConfig_sitename; ?>" href="<?php echo $link_file; ?>" />
         <?php
      }
   }

   // favourites icon
   if ( !$mosConfig_favicon ) {
      $mosConfig_favicon = 'favicon.ico';
   }
   $icon = $mosConfig_absolute_path .'/images/'. $mosConfig_favicon;
   // checks to see if file exists
   if ( !file_exists( $icon ) ) {
      $icon = $mosConfig_live_site .'/images/favicon.ico';
   } else {
      $icon = $mosConfig_live_site .'/images/' .$mosConfig_favicon;
   }

   // outputs link tag for page
   ?>
   <link rel="shortcut icon" href="<?php echo $icon;?>" />
   <?php
}
?>


Any idea on what I missed?

Your help is greatly appreciated!

~ Leisa

_________________
Leisa Watkins
http://www.WealthWisdomAndSuccess.com


Top
 Profile  
 
PostPosted: Fri Jul 11, 2008 7:13 pm 
Joomla! Intern
Joomla! Intern

Joined: Wed Sep 26, 2007 6:11 pm
Posts: 50
Location: Indianapolis
Leisa, I am quite the novice overall. But i followed the directions here and my site works as they said it would in regards to showing modules. I messed up the first time and had to grab a fresh frontend.php file from another install and then re-embedded the hack as they said to.

It works fine now.

My need was for modules i created, not ones i installed. So that is what led me to the custom.xml file.

As for the custom.xml, that is merely the standard xml file for any NEW modules you would create using the administrator backend. I use the NEW MODULE option to include modules with custom HTML within them, for example a SIGN ON image for a better look. If you edit and embed the params hack given in this topic, you now can HIDE OR NOT all NEW modules you create in the admin interface.

Hope that helps.

_________________
Only exact URLs allowed in signature. Please read Forum Rules: viewtopic.php?f=8&t=65


Top
 Profile  
 
PostPosted: Fri Jul 11, 2008 7:22 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Mon Oct 08, 2007 9:13 am
Posts: 148
Thanks for the reply.

I messed up a few times and figured that since I wasn't getting an errors the frontpage.php file was probably correct. The first three times I got errors. I'll try it again. My parameters show up ok in the modules so I think that is ok. So it must be related to the frontpage.php file I would guess. I've looked over it and don't see an error. Maybe the sixth time is a charm. We shall see.

I was wondering if it could have to do with cache not revealing the new page. But I've done a hard refresh.

~ Leisa

_________________
Leisa Watkins
http://www.WealthWisdomAndSuccess.com


Top
 Profile  
 
PostPosted: Sat Jul 12, 2008 6:14 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Mon Oct 08, 2007 9:13 am
Posts: 148
I don't know what I did wrong because in spite of not getting any error messages I still can't get this to work. Here is a work-around I did in case it may be of use to someone else.

I needed to hide modules for logged in users on the front page. So I included the module it in the intro of some content and selected to show on the front page. I included it by loading it to an unused position, and then added this to my content:
Code:
{mosloadposition user10}
.)

Then I wrapped it all in a
Code:
{noreg} Content {/noreg}
so that it wouldn't display once someone can sign-on.

So now I have a different frontpage for logged in users and for non-logged in users.

_________________
Leisa Watkins
http://www.WealthWisdomAndSuccess.com


Top
 Profile  
 
PostPosted: Wed Aug 13, 2008 7:39 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Wed Nov 07, 2007 7:58 pm
Posts: 270
Location: Auckland, New Zealand
See quote bellow:

I just recieved an e-mailing detailing the need to upgrade to 1.5.6 for security reasons. While trying to make changes to the patch (inorder to use this GREAT hack) I noticed that the render function looks different.... can this hack be applied to the 1.5.6 upgrade? :eek:

kevincam wrote:
Ok so I decided I really needed this too so I got it to work. But I'm no expert programmer either so if somebody knows a better way please let us know but here goes what worked for me.

Added this after the last parameter of the XML file for whatever module you want to hide for example the login module which is located here (modules\mod_login\mod_login.xml):

<param name="show_registered" type="radio" default="1" label="Show Menu When Logged In" description="Show the menu also when a registered user is logged in">
<option value="0">No</option>
<option value="1">Yes</option>
</param>


Then replace the function render( $position, $params = array(), $content = null ) in \libraries\joomla\document\html\renderer\modules.php with the following


function render( $position, $params = array(), $content = null )
{
$renderer =& $this->_doc->loadRenderer('module');

$contents = '';
foreach (JModuleHelper::getModules($position) as $mod) {
// HACK: added code to check if module should be shown when a user is logged in
$pattern = '/show_registered=0/';
$match = preg_match($pattern, $mod->params);
$userId = $_SESSION["__default"]['user']->id;
if ($match && $userId) {
// simply continue the loop without outputting this module
continue;
}
// --- end HACK ---
$contents .= $renderer->render($mod, $params, $content);
}
return $contents;
}


UPDATED: I noticed that modules that use the module count need an additional hack to the file:
\libraries\joomla\application\module\helper.php

after the line $modules = array();
and before the line $db->setQuery( $query );

//HACK check in logged in then run query to exclude the correct modules
if($userId = $_SESSION["__default"]['user']->id >0){
$wheremenu = isset( $Itemid ) ? ' AND ( mm.menuid = '. (int) $Itemid .' OR mm.menuid = 0 )' : '';
$query = 'SELECT id, title, module, position, content, showtitle, control, params'
. ' FROM #__modules AS m'
. ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'
. ' WHERE m.published = 1'
. ' AND m.access <= '. (int)$aid
. ' AND m.client_id = '. (int)$mainframe->getClientId()
. " AND m.id NOT IN (SELECT id FROM #__modules WHERE params LIKE '%show_registered=0%')"
. $wheremenu
. ' ORDER BY position, ordering';
}else{
$wheremenu = isset( $Itemid ) ? ' AND ( mm.menuid = '. (int) $Itemid .' OR mm.menuid = 0 )' : '';
$query = 'SELECT id, title, module, position, content, showtitle, control, params'
. ' FROM #__modules AS m'
. ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'
. ' WHERE m.published = 1'
. ' AND m.access <= '. (int)$aid
. ' AND m.client_id = '. (int)$mainframe->getClientId()
. $wheremenu
. ' ORDER BY position, ordering';
}
//HACK
/*ORIGINAL CODE
$wheremenu = isset( $Itemid ) ? ' AND ( mm.menuid = '. (int) $Itemid .' OR mm.menuid = 0 )' : '';
$query = 'SELECT id, title, module, position, content, showtitle, control, params'
. ' FROM #__modules AS m'
. ' LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'
. ' WHERE m.published = 1'
. ' AND m.access <= '. (int)$aid
. ' AND m.client_id = '. (int)$mainframe->getClientId()
. $wheremenu
. ' ORDER BY position, ordering';
ORIGINAL CODE*/

_________________
Andre
==============================
John 3 vs 16-17; Romans 10 vs 9


Top
 Profile  
 
PostPosted: Wed Aug 13, 2008 8:30 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jan 03, 2008 8:37 am
Posts: 17
Good question. I'd say if you got test platform give it try and let us know. I can't remember which site I used this on but I have patached all my sites.


Top
 Profile  
 
PostPosted: Fri Sep 12, 2008 5:30 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Oct 24, 2007 8:49 pm
Posts: 43
kevincam wrote:
Good question. I'd say if you got test platform give it try and let us know. I can't remember which site I used this on but I have patached all my sites.

Thanks Kevin! Works great on 1.5.7.


Top
 Profile  
 
PostPosted: Sat Oct 04, 2008 9:36 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Sep 23, 2008 5:16 am
Posts: 8
Thanks kevincam... it works like a charm on 1.5.7


Top
 Profile  
 
PostPosted: Thu Oct 09, 2008 10:01 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Nov 03, 2005 4:32 pm
Posts: 20
I had the same problem but didn't like the hack solution, so I made a quick module that allows you to select the module position to show to public and the one to show to members. It's joined with this message.


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
PostPosted: Sun Oct 12, 2008 4:39 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Nov 16, 2007 8:13 am
Posts: 5
hi guys.. thanks Kevin for the great workaround for Joomla 1.5 :D

But I love how phlux0r did with the user category. And I really need each user category to be able to see or not some modules. Is there any1 have the workaround?

With Kevin's workaround, we can only hide modules from registered user, regardless of the status (author, editor, etc). So.. any1 can add this little feature into it?

FYI, I'm not a programmer at all ;)


Top
 Profile  
 
PostPosted: Tue Oct 14, 2008 11:49 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Nov 16, 2007 8:13 am
Posts: 5
any1?


Top
 Profile  
 
PostPosted: Tue Oct 14, 2008 12:03 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Oct 24, 2007 8:49 pm
Posts: 43
radicalz wrote:
any1?

I'm just going to throw my 2 cents in on this one since I'm not a programmer either, but I've read that Joomla 1.6 will have better ACL, so it might be worth waiting for this instead of hacking the core now. If it's really necessary, try joomsuite.com JPermissions. This will surely help you with your problem this case if you are running Joomla 1.5.x. Sorry I couldn't be more helpful.


Top
 Profile  
 
PostPosted: Mon Oct 20, 2008 7:44 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Tue May 16, 2006 9:58 pm
Posts: 1
this hack works great on joomla 1.57 thanks, i am new to all the coding side of joomla and i was wondering if there is anyway this code can be converted to use jaclplus or jaclplus pro.
thanks for any help you can give :)


Top
 Profile  
 
PostPosted: Fri Oct 24, 2008 3:12 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Oct 24, 2007 8:49 pm
Posts: 43
This hack was working perfectly for me before populating my site, but now that I have a YooTheme template, I keep getting the following error:


Fatal error: Call to undefined method JDocumentError::countModules() in /public_html/templates/yoo_shuffle/lib/php/yoolayout.php on line 101

Code:
// set css-class for layoutstyle
if ($this->countModules('left')) {
   if ($this->params->get('layout') == 'left') {
      $this->params->set('leftcolumn', 'left');
   } else {
      $this->params->set('leftcolumn', 'right');
   }
}


I notified YooTheme but no response. Hopefully I can find someone to save me here! Thanks!


Top
 Profile  
 
PostPosted: Wed Nov 12, 2008 3:29 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Oct 01, 2007 11:35 am
Posts: 522
I happened across this thread thanks to this article: http://www.welcometojoomla.com/how-do-i/hide-module.html.

For all those who want to hide a module from registered users who are logged in, there is a simple solution: just download Mod OnAnyPage from the JED (http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,6418/Itemid,35/).

This is a module that can show or hide other modules dependent on various checks, and one of the checks is for registered users. All you would need to do is to install Mod OnAnypage, to choose some settings and enable it, and to pubish the target module to a different position. Much quicker and simpler than hacking!

By publishing a (copy of a) menu module (with selected items) through Mod OnAnyPage you can also hide menus for registered users. It does much more than that, but what it does not do (yet, but these are on the wishlist) is checking for various levels of users and for https. However, Mod OnAnyPage does work with any version of J!1.5. There is a slightly more limited J!1.0.x version which is no longer maintained but on strong demand could be updated.

Now that it is no longer necessary, I would avoid hacking this functionality into Joomla unless you want to repeat the exercise everytime a new version comes out, such as the security release this week.

Mod OnAnyPage is new (actually I made it a year ago but never got to distribute it) but unless I am mistaken Meta Mod was already capable of hiding modules from logged in users - be it with more effort (see the JED: http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,3391/Itemid,35/).

If you use it and you have any feedback please let me know (but preferably not in this thread). I am not a coder and merely a hobbyist, but I am trying to do what I can to improve or work around the Joomla menu assignment system (see also this thread: http://forum.joomla.org/viewtopic.php?f=502&t=266002).


Top
 Profile  
 
PostPosted: Wed Nov 12, 2008 3:46 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Oct 24, 2007 8:49 pm
Posts: 43
ewel wrote:
Mod OnAnyPage is new (actually I made it a year ago but never got to distribute it) but unless I am mistaken Meta Mod was already capable of hiding modules from logged in users - be it with more effort (see the JED: http://extensions.joomla.org/component/option,com_mtree/task,viewlink/link_id,3391/Itemid,35/).


Meta Mod does a great job of hiding modules for various situations. I originally posted here to commend the hack, but after 2 updates it's just a pain to keep up. Meta Mod works well, but I would say it's an advanced level module that requires at least a basic understanding of php. It's worth the time to figure it out, though!

Kevin


Top
 Profile  
 
PostPosted: Wed Nov 12, 2008 3:58 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Oct 01, 2007 11:35 am
Posts: 522
kwoolf wrote:
Meta Mod does a great job of hiding modules for various situations. I originally posted here to commend the hack, but after 2 updates it's just a pain to keep up. Meta Mod works well, but I would say it's an advanced level module that requires at least a basic understanding of php. It's worth the time to figure it out, though!

Kevin


I thought so.. and I agree Meta Mod is for advanced users (it revolves around geo-location so it is probably most popular with developers of ecommerce sites). One of the reasons why I decided to finally publish Mod OnAnyPage is because it requires zero understanding of php so anyone can use it.


Top
 Profile  
 
PostPosted: Fri May 22, 2009 1:37 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Sat Jan 14, 2006 1:59 pm
Posts: 181
Location: Sunderland UK
I used this a while ago and it worked a treat

for example i needed if you were logged out, to see a login module, or if you were logged in to see content.

Code:
             <?php
            if ($my->id ) {
               echo "<div id=\"rightmain0\"><jdoc:include type=\"component\" /></div>
      </div>";
            } else {
               echo "<div id=\"rightmainlogged\">
               <div id=\"divContentlogged\">
               <jdoc:include type=\"modules\" name=\"user5\" headerLevel=\"3\" />
            </div> ";
            }
            ?>

And it worked perfect

Just add that in where you need to add in the module position etc, of course modify the code to suit, such as you could use

Code:
<?php
            if ($my->id ) {
               echo "<jdoc:include type=\"modules\" name=\"user2\" headerLevel=\"3\" />";
            } else {
               echo "<jdoc:include type=\"modules\" name=\"user3\" headerLevel=\"3\" />";
            }
?>

To just switch between modules

You can see it by going to the test site i made it on
http://host2.newworldhosting.co.uk/~wwwcarr/
Then clicking on "available works" and logging in or out with
Username - test
Password - test

That is working on Joomla 1.5.10 at the moment.

_________________
http://www.JoomlaSiteMonitor.com
Joomla Security and backup suite.
http://www.NewWorldDesigns.co.uk
Design - CMS - Ecommerce – SEO


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 111 posts ]  Go to page Previous  1, 2, 3, 4  Next



Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group