php - Adding Anchor to every module in Joomla 3.1 -
i trying modify module template code add anchor title of each module. have extremely limited php knowledge, guidance helpful.
i've found posts doing articles, code appears different modules.
this code in module template.
function modchrome_basic($module, &$params, &$attribs) { if (!empty ($module->content)) : ?> <?php echo $module->content; ?> <?php endif; } function modchrome_standard($module, &$params, &$attribs) { if (!empty ($module->content)) : ?> <div class="rt-block <?php if ($params->get('moduleclass_sfx')!='') : ?><?php echo $params->get('moduleclass_sfx'); ?><?php endif; ?>"> <div class="module-surround"> <?php if ($module->showtitle != 0) : ?> <div class="module-title"> <?php echo '<h2 class="title">'; if (preg_match("/icon[-]{1,}/i", $params->get('moduleclass_sfx'))) : echo '<span class="title-icon ' .geticonclass($params->get('moduleclass_sfx')). '"></span>'; endif; echo $module->title; echo '</h2>'; ?> </div> <?php endif; ?> <div class="module-content"> <?php echo $module->content; ?> </div> </div> </div> <?php endif;
} code tried
if( strlen($this->item->params->get('title')) > 0 ) { echo '<a name="'.$this->item->params->get('title').'"></a>'; }
i tried
if( strlen($module->item->params->get('title')) > 0 ) { echo '<a name="'.$module->item->params->get('title').'"></a>'; }
joomla has easy way customize module appearance.
you have use custom module chrome.
you have create modules.php
file under /templates/template_name/html/modules.php
.
inside file have put:
<?php function modchrome_custom( $module, &$params, &$attribs ) { echo '<div id="' .$params->get( 'moduleclass_sfx' ) .'" >'; if ($module->showtitle) { echo '<h' .$headerlevel .'>' .$module->title .'</h' .$headerlevel .'>'; } echo '<div class="module_content">'; echo $module->content; echo '</div>'; echo '</div>'; } ?>
in code above module id getting moduleclass_sfx
value. change , set module variable.
in order use appearence have set appropriate style
template module calls like: <jdoc:include type="modules" name="user1" style="custom" />
if want use style name have change function modchrome_custom
modchrome_newstyle
.
good luck!
Comments
Post a Comment