test
Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • nigelmaine Friend
    #325121

    Hi

    Live url as requested http://www.clearvoice.co.uk – site map

    As you can see, the site map creates the name with Module at the begining of How we can halp and Register, as these are in the menu set up.

    Kind Regards

    Nigel

    prakash Friend
    #325123

    Hi,

    For this first take a backup of your existing xmap.html.php file in componentscom_xmapxmap.html.php

    Now replace your existing file with this content: (this is the entire file for xmap.html.php)

    <?php
    /**
    * $Id: xmap.html.php 24 2009-03-13 15:05:30Z guilleva $
    * $LastChangedDate: 2009-03-13 09:05:30 -0600 (Fri, 13 Mar 2009) $
    * $LastChangedBy: guilleva $
    * Xmap by Guillermo Vargas
    * A Sitemap component for Joomla! CMS (http://www.joomla.org)
    * Author Website: http://joomla.vargas.co.cr
    * Project License: GNU/GPL http://www.gnu.org/copyleft/gpl.html
    */

    defined('_JEXEC') or die('Direct Access to this location is not allowed.');

    /** Wraps HTML output */
    class XmapHtml extends Xmap {
    var $level = -1;
    var $_openList = '';
    var $_closeList = '';
    var $_closeItem = '';
    var $_childs;
    var $_width;
    var $_isAdmin = 0;

    function XmapHtml (&$config, &$sitemap) {
    $this->view = 'html';
    Xmap::Xmap($config, $sitemap);
    $this->_parent_children=array();
    $this->_last_child=array();
    }

    /**
    * Print one node of the sitemap
    */
    function printNode( &$node ) {
    global $Itemid;

    $out = '';

    if ($this->sitemap->isExcluded($node->id,$node->uid) && !$this->_isAdmin) {
    return FALSE;
    }

    // To avoid duplicate children in the same parent
    if ( !empty($this->_parent_children[$this->level][$node->uid]) ) {
    return FALSE;
    }

    //var_dump($this->_parent_children[$this->level]);
    $this->_parent_children[$this->level][$node->uid] = true;

    $out .= $this->_closeItem;
    $out .= $this->_openList;
    $this->_openList = "";

    if ( $Itemid == $node->id )
    $out .= '<li class="active">';
    else
    $out .= '<li>';

    $link = Xmap::getItemLink($node);

    if( !isset($node->browserNav) )
    $node->browserNav = 0;

    $node->name = htmlspecialchars($node->name);

    //code modified by : Prakash R Balge.
    //Author Website : http://www.classifiedsnext.com
    $testavaluetoday = htmlspecialchars($node->name);
    $returnedvaluetoday = strpos($testavaluetoday,"[");
    $returnedvalueendday = strpos($testavaluetoday, "]");
    if ($returnedvaluetoday != 0){
    if($returnedvalueendday == (strlen($testavaluetoday)-1)) {
    $finalvalueretrievedtoday = substr($testavaluetoday,0,$returnedvaluetoday-1);
    } else {
    $menunamestart = substr($testavaluetoday,0,$returnedvaluetoday-1);
    $menunameend = substr($testavaluetoday,$returnedvalueendday+1,(strlen($testavaluetoday)-$returnedvalueendday));
    if ($menunamestart=="module")
    {$menunamestart = "";}
    $finalvalueretrievedtoday = $menunamestart." ".$menunameend;
    }

    }
    else{
    $finalvalueretrievedtoday = htmlspecialchars($node->name);
    }
    //end of code modified by : Prakash R Balge

    switch( $node->browserNav ) {
    case 1: // open url in new window
    $ext_image = '';
    if ( $this->sitemap->exlinks ) {
    $ext_image = ' <img src="'. $this->live_site .'/components/com_xmap/images/'. $this->sitemap->ext_image .'" alt="' . _XMAP_SHOW_AS_EXTERN_ALT . '" title="' . _XMAP_SHOW_AS_EXTERN_ALT . '" border="0" />';
    }
    //code modified by : Prakash R Balge.
    //Author Website : http://www.classifiedsnext.com
    $out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'" target="_blank">'. $finalvalueretrievedtoday . $ext_image .'</a>';
    //end of code modified by : Prakash R Balge
    break;

    case 2: // open url in javascript popup window
    $ext_image = '';
    if( $this->sitemap->exlinks ) {
    $ext_image = ' <img src="'. $this->live_site .'/components/com_xmap/images/'. $this->sitemap->ext_image .'" alt="' . _XMAP_SHOW_AS_EXTERN_ALT . '" title="' . _XMAP_SHOW_AS_EXTERN_ALT . '" border="0" />';
    }
    //code modified by : Prakash R Balge.
    //Author Website : http://www.classifiedsnext.com
    $out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'" target="_blank" '. "onClick="javascript: window.open('". $link ."', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false;">". $finalvalueretrievedtoday . $ext_image."</a>";
    //end of code modified by : Prakash R Balge
    break;

    case 3: // no link
    //code modified by : Prakash R Balge.
    //Author Website : http://www.classifiedsnext.com
    $out .= '<span>'. $finalvalueretrievedtoday .'</span>';
    //end of code modified by : Prakash R Balge
    break;

    default: // open url in parent window
    //code modified by : Prakash R Balge.
    //Author Website : http://www.classifiedsnext.com
    $out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'">'. $finalvalueretrievedtoday .'</a>';
    //end of code modified by : Prakash R Balge
    break;
    }

    $this->_closeItem = "</li>n";
    $this->_childs[$this->level]++;
    echo $out;

    if ($this->_isAdmin) {
    if ( $this->sitemap->isExcluded($node->id,$node->uid) ) {
    $img = '<img src="'.$this->live_site.'/administrator/images/publish_x.png" alt="'._XMAP_EXT_PUBLISHED.'" title="'._XMAP_EXT_UNPUBLISHED.'">';
    $class= 'xmapexclon';
    } else {
    $img = '<img src="'.$this->live_site.'/administrator/images/tick.png" alt="'._XMAP_EXT_PUBLISHED.'" title="'._XMAP_EXT_PUBLISHED.'" />';
    $class= 'xmapexcloff';
    }
    echo ' <a href= "#" class="xmapexcl '.$class.'" rel="{uid:''.$node->uid.'',itemid:'.$node->id.'}">'.$img.'</a>';
    # echo ' <a href= "#" class="xmapoptions" rel="{uid:''.$node->uid.'',itemid:'.$node->id.'}"><img src="'.$this->live_site.'/components/com_xmap/images/options.gif" border="0" alt="Options" title="Options" /></a>';
    }
    //echo $this->_last_child[$this->level-1] . ' ' . $this->_parent_children[$this->level]['parent'];
    $this->count++;

    $this->_last_child[$this->level] = $node->uid;

    return TRUE;
    }

    /**
    * Moves sitemap level up or down
    */
    function changeLevel( $level ) {
    if ( $level > 0 ) {
    # We do not print start ul here to avoid empty list, it's printed at the first child
    $this->level += $level;
    $this->_childs[$this->level]=0;
    $this->_openList = "n<ul class="level_".$this->level."">n";
    $this->_closeItem = '';

    // If we are moving up, then lets clean the children of this level
    // because for sure this is a new set of links
    if ( empty ($this->_last_child[$this->level-1]) || empty ($this->_parent_children[$this->level]['parent']) || $this->_parent_children[$this->level]['parent'] != $this->_last_child[$this->level-1] ) {
    $this->_parent_children[$this->level]=array();
    $this->_parent_children[$this->level]['parent'] = @$this->_last_child[$this->level-1];
    }
    } else {
    if ($this->_childs[$this->level]){
    echo $this->_closeItem."</ul>n";
    }
    $this->_closeItem ='</li>';
    $this->_openList = '';
    $this->level += $level;
    }
    }

    /** Print component heading, etc. Then call getHtmlList() to print list */
    function startOutput(&$menus,&$config) {
    global $database, $Itemid;
    $sitemap = &$this->sitemap;
    $this->live_site = substr_replace(JURI::root(), "", -1, 1);

    $user = &JFactory::getUser();

    if ($this->_isAdmin) {
    JHTML::_('behavior.mootools');
    $live_site = JURI::root();
    $ajaxurl = "$live_site/index.php?option=com_xmap&tmpl=component&task=editElement&action=toggleElement";

    $css = '.xmapexcl img{ border:0px; }'."n";
    $css .= '.xmapexcloff { text-decoration:line-through; }';
    //$css .= "n.".$this->sitemap->classname .' li {float:left;}';

    $js = "
    window.addEvent('domready',function (){
    $$('.xmapexcl').each(function(el){
    el.onclick = function(){
    if (this && this.rel) {
    options = Json.evaluate(this.rel);
    this.onComplete = checkExcludeResult
    var myAjax = new Ajax('{$ajaxurl}&sitemap={$this->sitemap->id}&uid='+options.uid+'&itemid='+options.itemid,{
    onComplete: checkExcludeResult.bind(this)
    }).request();
    }
    return false;
    };

    });
    });
    checkExcludeResult = function (txtresponse,xmlresponse) {
    //this.set('class','xmapexcl xmapexcloff');
    var imgs = this.getElementsByTagName('img');
    var response = xmlresponse.getElementsByTagName('response')[0];
    var result = response.getElementsByTagName('result')[0].firstChild.nodeValue;
    if (result == 'OK') {
    var state = response.getElementsByTagName('state')[0].firstChild.nodeValue;
    if (state==0) {
    imgs[0].src='{$live_site}administrator/images/publish_x.png';
    } else {
    imgs[0].src='{$live_site}administrator/images/tick.png';
    }
    } else {
    alert('The element couldn\'t be published or upublished!');
    }
    }";

    $doc = JFactory::getDocument();
    $doc->addStyleDeclaration ($css);
    $doc->addScriptDeclaration ($js);
    }

    $menu = &JTable::getInstance('Menu');
    $menu->load( $Itemid ); // Load params for the Xmap menu-item
    $params = new JParameter($menu->params);
    $title = $params->get('page_title',$menu->name);

    $exlink[0] = $sitemap->exlinks; // image to mark popup links
    $exlink[1] = $sitemap->ext_image;

    if( $sitemap->columns > 1 ) { // calculate column widths
    $total = count($menus);
    $columns = $total < $sitemap->columns ? $total : $sitemap->columns;
    $this->_width = (100 / $columns) - 1;
    }
    echo '<div class="'. $sitemap->classname .'">';

    if ( $params->get( 'show_page_title' ) ) {
    echo '<div class="componentheading">'.$title.'</div>';
    }
    echo '<div class="contentpaneopen"'. ($sitemap->columns > 1 ? ' style="float:left;width:100%;"' : '') .'>';

    }

    /** Print component heading, etc. Then call getHtmlList() to print list */
    function endOutput(&$menus) {
    global $database, $Itemid;
    $sitemap = &$this->sitemap;

    echo '<div style="clear:left"></div>';
    //BEGIN: Advertisement
    if( $sitemap->includelink ) {
    echo "<div style="text-align:center;"><a href="http://joomla.vargas.co.cr" style="font-size:10px;">Powered by Xmap!</a></div>";
    }
    //END: Advertisement

    echo "</div>";
    echo "</div>n";
    }

    function startMenu(&$menu) {
    $sitemap=&$this->sitemap;
    if( $sitemap->columns > 1 ) // use columns
    echo '<div style="float:left;width:'.$this->_width.'%;">';
    if( $sitemap->show_menutitle ) // show menu titles
    echo '<h2 class="menutitle">'.$menu->name.'</h2>';
    }

    function endMenu(&$menu) {
    $sitemap=&$this->sitemap;
    $this->_closeItem='';
    if( $sitemap->show_menutitle || $sitemap->columns > 1 ) { // each menu gets a separate list
    if( $sitemap->columns > 1 ) {
    echo "</div>n";
    }

    }
    }
    }

    nigelmaine Friend
    #325140

    Hi

    Once again, many thanks. It looks great.

    All the very best.

    Kind Regard

    Nigel

    socoweb Friend
    #330239

    I found that the best results for integrating XMAP and JA Mega Menu was to modify the xmap.php files per prbalge’s solution. Also adding an extra space after the name of the menu item:

    MenuName []sub text

    ensured that the last character of the menu name appeared in the site map.

    With the replacement code for the xmap.php file, the last character before the [ symbol was not appearing on the site map.

    BTW, I use JOOMAce SEF, which I have found to be better suited to SEO than SH404SEF (although SH404 SEF is a very fine solution as well.

Viewing 4 posts - 16 through 19 (of 19 total)

This topic contains 19 replies, has 4 voices, and was last updated by  socoweb 14 years, 10 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum