PDA

View Full Version : Sitemap-Modification > UL/LI


Tobias
27.04.2004, 13:35
Hi!

Maybe someone does find this modification useful.
And maybe there is someone to complete some unsolved task.

I tried - and partly succeeded - to modify the Sitemap-Component (MOSForge-Projektpage) (http://mosforge.net/projects/sitemap/):

Done:

generate UL-/LI-List instead of HTML-List
by this more ore less deactivated the "two collum"-function - this sould be done in css (see html-form-experiment to see what is possible with css (http://www.themaninblue.com/experiment/InForm/))
use <h1> for headline
be xMambo-compatible


Now the Sitemap is:

(nearly) right/valid xhtml-semantic (see SimpleBits-Quiz for nice discussions about semantic (http://www.simplebits.com/archives/simplequiz/index.html)
nice non-styled-view als unordered list
easily style-able with CSS -- everything that is possible with the HTML-Vesion is now possible with CSS (more information about this on request)


ToDo:

more source changes to correctly wrap second-level-UL in parent-level LI (like this: <ul><li>1<ul><li>1.1</li><li>1.2</li></ul></li><li>2</li></ul>)
Wishlist: Selectionbox for MyMenu-Menus (see MOSForge-Featurerequest) (http://mosforge.net/tracker/?atid=116&group_id=8&func=browse)


Replace your sitemap.html.php from line 95 up to line 349.
Remember to change your CSS as well!

/**
* Create one output row
*/
function _showRow(&$row, $numColumns, $sitemapManager)
{
global $mosConfig_live_site;

for( $i=0; $i<$numColumns; $i++ ) {
if ( isset($row[$i]) ) {

$icons='';
if ( $row[$i]->access > 0 && $sitemapManager->getCfg( 'showRestrictedIcon' )) {
$icons .= '<img src="components/com_sitemap/images/lock.png" alt="' ._SITEMAP_RESTRICTED_CONTENT. '" border="0">';
}
if ( $row[$i]->type=='url' && $sitemapManager->getCfg( 'showURLIcon' )
&& strpos ($row[$i]->link, 'http') > 0) {
$icons .= '<img src="images/M_images/weblink.png" alt="' ._SITEMAP_EXTERNAL_CONTENT. '" border="0">';
}


switch ( $row[$i]->level ) {
case 0:
// echo '<td colspan="5" width="100%" nowrap class="' .$sitemapManager->getCfg( 'styleMainmenu' ). '">';
echo '<li>';
echo $row[$i]->link;
if ($icons!='') {
echo '<span>'.$icons.'</span>';
}
echo "</a></li>\n";
break;

case 1:
// echo '<td>&nbsp;</td><td colspan="4" width="100%" nowrap class="' .$sitemapManager->getCfg( 'styleSubmenu' ). '">';
echo '<li class="zwei">';
echo $row[$i]->link;
if ($icons!='') {
echo '<span>'.$icons.'</span>';
}
echo "</a></li>\n";
break;

case 2:
// echo '<td>&nbsp;</td><td>&nbsp;</td><td colspan="3" width="100%" nowrap class="' .$sitemapManager->getCfg( 'styleSubmenu' ). '">';
echo '<li class="drei">';
echo $row[$i]->link;
if ($icons!='') {
echo '<span>'.$icons.'</span>';
}
echo "</a></li>\n";
break;

case 3:
// echo '<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td colspan="2" width="100%" nowrap class="' .$sitemapManager->getCfg( 'styleSubmenu' ). '">';
echo '<li class="vier">';
echo $row[$i]->link;
if ($icons!='') {
echo '<span>'.$icons.'</span>';
}
echo "</a></li>\n";
break;

case 4:
// echo '<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>';
echo '<br />';
break;
}

//echo $row[$i]->link;

/*if ($icons!='') {
echo '<span>'.$icons.'</span>';
} else {
echo "";
}*/

//echo "</li>/n;";

}
else {
// echo '<td colspan="6">&nbsp;</td>';
echo '<br />';
}
}
}

/**
* Function to write the header of the map
*/
function _header() {
global $mainframe;
?>

<!-- <div id="Sitemap"> -->
<div class="contentheading"><h1 class="sitemap"><?php echo _SITEMAP_TITLE . $mainframe->getCfg('sitename');?></h1></div>
<ul class="sitemap">

<?php
$numColumns = $this->_sitemapManager->getCfg('numColumns');
for($i=0; $i<$numColumns; $i++) {
/* del */
}
}

/**
* Function to write the footer of the map
*/
function _footer() {
?>

</ul>
<!-- </div> -->

<!--SiteMap <?php echo $this->_sitemapManager->getVersion();?>-->
<!-- &copy; 2003 Think Network, released under the GPL. -->
<!-- More information: at http://www.ThinkNetwork.com -->
<?php
}

/**
* This functions splits the whole map into a certain number of pieces
*
*/
function _splitMap( $wholeSiteMap, $numColumns ) {
$columnMap = array();

$mapBreak = count($wholeSiteMap) / $numColumns;
$lastBreak = 0;

for( $col=0; $col<$numColumns-1; $col++) {
$level0Break=-1;
for( $i=$mapBreak+1; $i<count($wholeSiteMap); $i++ ) {
if( $wholeSiteMap[$i]->level==0 ) {
$level0Break=$i;
break;
}
}
$columnMap[$col]=array_slice( $wholeSiteMap, $lastBreak, $level0Break-1 );
$lastBreak=$level0Break-1;
}
$columnMap[$col]=array_slice( $wholeSiteMap, $lastBreak );

$maxRows=0;
for( $i=0; $i<$numColumns; $i++ ) {
if ( count($columnMap[$i])>$maxRows ) {
$maxRows = count($columnMap[$i]);
}
}
$splittedMap = array();
for( $col=0; $col<$numColumns; $col++ ) {
for( $i=0; $i<$maxRows; $i++ ) {
if ( !isset($columnMap[$col][$i]) ) continue;
$splittedMap[$i][$col]=$columnMap[$col][$i];
}
}
return $splittedMap;
}

/**
* Builds the map of all the menus
*/
function _buildMenuMap(&$siteMap)
{
global $database, $my;

$menuMap=null;
$published = 'AND published=1';
if ($this->_sitemapManager->getCfg('showPublishedContent')==false) {
$published = '';
}

// Shows only Mainmenu
$sql = "SELECT m.* FROM #__menu AS m"
. "\nWHERE menutype='mainmenu' $published AND access <= $my->gid"
. "\nORDER BY sublevel,ordering";

// Shows all (MyMenu)-Menu
// except the usermenu
// THX @ http://www.mambers.com/showthread.php?t=1453&highlight=sitemap
// even better would be to have a flag in MyMenu which says "add me to sitemap" > http://mosforge.net/tracker/index.php?func=detail&aid=544&group_id=8&atid=116

/* $sql = "SELECT m.* FROM #__menu AS m"
. "\nWHERE menutype!='usermenu' $published AND access <= $my->gid"
. "\nORDER BY sublevel,ordering"; */

$database->setQuery( $sql );

$rows = $database->loadObjectList( 'id' );
echo $database->getErrorMsg();

// establish the hierarchy of the menu
$children = array();
// first pass - collect children
foreach ($rows as $v ) {
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push( $list, $v );
$children[$pt] = $list;
}
$menuMap = $children;

$siteMap = array();
$this->_recurseMenu( 0, 0, $menuMap, $siteMap );

}

/**
* Recurse the menu and build it up for all levels
*/
function _recurseMenu( $id, $level, &$menuMap, &$siteMap ) {
global $mosConfig_lang, $mosConfig_mbf_content;
if (@$menuMap[$id]) {

/*echo "<ul class=\"testa\">";*/

foreach ($menuMap[$id] as $row) {
$menuLink='';

if ($row->type != 'url') {
$row->link .= "&Itemid=$row->id";
}
// akede, 2003-11-07: Support for multi language component MambelFish added
if (isset($mosConfig_mbf_content) && $mosConfig_mbf_content) {
$row = MambelFish::translate( $row, 'menu', $mosConfig_lang);
}
$row->link = sefRelToAbs($row->link);

// END: akede
if ($level == 0) {
$menuclass = $this->_sitemapManager->getCfg( 'styleMainmenu' );
} else {
$menuclass = $this->_sitemapManager->getCfg( 'styleAnchorTag' );
}

switch ($row->browserNav) {
// cases are slightly different
case 1:
// open in a new window
// $menuLink = "<a href=\"$row->link\" target=\"_window\" class=\"$menuclass\">$row->name</a>\n";
$menuLink = "<a href=\"$row->link\" target=\"_window\" class=\"linknewwin\">$row->name";
break;

case 2:
// open in a popup window
// $menuLink = "<a href=\"#\" onClick=\"javascript: window.open('$row->link', '', 'toolbar=no,location=no,status=no,menubar=no,scrol lbars=yes,resizable=yes,width=780,height=550');\" class=\"$menuclass\">$row->name</a>\n";
$menuLink = "<a href=\"#\" onClick=\"javascript: window.open('$row->link', '', 'toolbar=no,location=no,status=no,menubar=no,scrol lbars=yes,resizable=yes,width=780,height=550');\" class=\"linkpopup\">$row->name";
break;

default: // formerly case 2
// open in parent window
// $menuLink = "<a href=\"$row->link\" class=\"$menuclass\">$row->name</a>\n";
$menuLink = "<a href=\"$row->link\">$row->name";
break;
}

$rowNum = count($siteMap)+1;
$siteMap[$rowNum] = new stdClass();
$siteMap[$rowNum]->link = $menuLink;
$siteMap[$rowNum]->type = $row->type;
$siteMap[$rowNum]->level = $level;
$siteMap[$rowNum]->componentid = $row->componentid;
$siteMap[$rowNum]->access = $row->access;

if ($this->_sitemapManager->getCfg('showSubmenus')) {
/*echo "<ul class=\"testB\">";*/
$this->_recurseMenu( $row->id, $level+1, $menuMap, $siteMap );
/*echo "</ul>";*/
}
}

/*echo "</ul>";*/

}
}


Would be glad to get some feedback.html-form-experiment to see what is possible with css (http://www.themaninblue.com/experiment/InForm/)

eyezberg
27.04.2004, 18:51
Is it online somewhere to take a look at? Thanks

Tobias
27.04.2004, 22:50
Answer via PM.

Update 03/2005: see http://www.bvgc.de/component/option,com_sitemap/Itemid,146/

Skumlingen
14.03.2005, 12:18
Any update on this????? :confused: :question:


Hi!

Maybe someone does find this modification useful.
And maybe there is someone to complete some unsolved task.

I tried - and partly succeeded - to modify the Sitemap-Component (MOSForge-Projektpage) (http://mosforge.net/projects/sitemap/):

Done:

generate UL-/LI-List instead of HTML-List
by this more ore less deactivated the "two collum"-function - this sould be done in css (see html-form-experiment to see what is possible with css (http://www.themaninblue.com/experiment/InForm/))
use <h1> for headline
be xMambo-compatible


Now the Sitemap is:

(nearly) right/valid xhtml-semantic (see SimpleBits-Quiz for nice discussions about semantic (http://www.simplebits.com/archives/simplequiz/index.html)
nice non-styled-view als unordered list
easily style-able with CSS -- everything that is possible with the HTML-Vesion is now possible with CSS (more information about this on request)


ToDo:

more source changes to correctly wrap second-level-UL in parent-level LI (like this: <ul><li>1<ul><li>1.1</li><li>1.2</li></ul></li><li>2</li></ul>)
Wishlist: Selectionbox for MyMenu-Menus (see MOSForge-Featurerequest) (http://mosforge.net/tracker/?atid=116&group_id=8&func=browse)


Replace your sitemap.html.php from line 95 up to line 349.
Remember to change your CSS as well!

Code erased...


Would be glad to get some feedback.html-form-experiment to see what is possible with css (http://www.themaninblue.com/experiment/InForm/)

Tobias
14.03.2005, 13:56
No, no update.
See upove Posting (updated) vor sample-URL.
If you change something, post it here.