1
gppetersen
Re: Adding menu highlighting and a hook for bread-crumbs
  • 2004/12/16 6:05

  • gppetersen

  • Just popping in

  • Posts: 3

  • Since: 2004/11/23


The best solution would be create a new block for the breadcrumb.
But, if you don't need the side menu, you could use a different system_block_mainmenu.html and the menu block will make a bread crumb.
WTF is up with the preview here ???
(warning I'm thinking off the top of my head and haven't tried this code:)
<table cellspacing="0">
<tr>
<td id="mainmenu">
<a class="menubreadcrumb" href="<{$xoops_url}>/"><{$block.lang_home}></a>
<!-- start module menu loop -->
<{foreach item=module from=$block.modules}>
<{if ( $module.current == 1 )}>
<a class="menubreadcrumb" href="<{$xoops_url}><{$module.directory}>/">
<{$module.name}>
</a>
<{/if}>
<{foreach item=sublink from=$module.sublinks}>
<{if ( $sublink.current == 1 )}>
<a class="menubreadcrumb" href="<{$sublink.url}>">
<{$sublink.name}>
</a>
<{/if}>
<{/foreach}>
<{/foreach}>
<!-- end module menu loop -->
</td>
</tr>
</table>



2
gppetersen
Adding menu highlighting and a hook for bread-crumbs
  • 2004/12/3 4:15

  • gppetersen

  • Just popping in

  • Posts: 3

  • Since: 2004/11/23


This is a hack to allow the current menu and sub menu selection to be high-lighted.
It could also form the base for a breadcrumb block.

I hope this is the right forum.

The idea is to add a .current var to the $blocks array that is used by system_block_mainmenu.html.
Smarty logic can then be used to make the current selection look different.

A bread crumb block could loop through the $blocks the way system_block_mainmenu.html does and use only the .current links to make a bread crumb trail.

limitations:
If you have a module as your default page, the home link will not be high lighted.

3 files are changed:
Changes required to modules/system/blocks/system_blocks.php
Changes required to system_block_mainmenu.html
Changes optional to /xoops.css to indicate the current menu choice.

system_blocks.php: (Only the function b_system_main_show()
is changed. Here it is.)

// GPP added .current to module and sublink allow color menu and bread crumbs
// NB:: requires changes to system_block_mainmenu.html!
function b_system_main_show()
{
/* GPP seems to generate the info for the menu
* add $block[modules][$i][current] set if we are on this page.
* $blockmodules[$i][sublinks][$j][current] set if we are using this sublink.
*/
// Get the module path and any script name.
$gppath = pathinfo($_SERVER['PHP_SELF']);
$gpcurrentsub = $gppath['basename'];
$gpcurrentmenu = $gppath['dirname'];
// special case: home should be "" not "/"
if ($gpcurrentmenu == "/"){
$gpcurrentmenu = "";
}
// normal service resumes...
global $xoopsUser,$xoopsModule;
$block = array();
$block['lang_home'] = _MB_SYSTEM_HOME;
$block['lang_close'] = _CLOSE;
$module_handler =& xoops_gethandler('module');
$criteria = new CriteriaCompo(new Criteria('hasmain', 1));
$criteria->add(new Criteria('isactive', 1));
$criteria->add(new Criteria('weight', 0, '>'));
$modules =& $module_handler->getObjects($criteria, true);
$moduleperm_handler =& xoops_gethandler('groupperm');
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
$read_allowed =& $moduleperm_handler->getItemIds('module_read', $groups);
// GPP add the home entry here not in system_block_mainmenu.html
// TODO: use the language file for 'Home'
$block['modules'][0]['name'] = 'Home';
$block['modules'][0]['directory'] = '';
if ($gpcurrentmenu == ""){
$block['modules'][0]['current'] = 1;
}else{
$block['modules'][0]['current'] = 0;
}
$block['modules'][0]['sublinks'] = array();
// resume normal service
foreach (array_keys($modules) as $i) {
if (in_array($i, $read_allowed)) {
$block['modules'][$i]['name'] = $modules[$i]->getVar('name');
// GPP put the full path in dirname so we don't have to add it in
// system_block_mainmenu.html and tests look better.
$block['modules'][$i]['directory'] = '/modules/' . $modules[$i]->getVar('dirname');
// GPP set/clear .current if this is [not]where we are.
if ($block['modules'][$i]['directory'] == $gpcurrentmenu){
$block['modules'][$i]['current'] = 1;
}else{
$block['modules'][$i]['current'] = 0;
}
$sublinks =& $modules[$i]->subLink();
if ((count($sublinks) > 0) && (!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) {
foreach($sublinks as $sublink){
// GPP add .current=[1|0] if we are [not]using this link to the sublinks.
if ($sublink['url'] == $gpcurrentsub){
$block['modules'][$i]['sublinks'][] = array('current' => 1, 'name' => $sublink['name'], 'url' => XOOPS_URL.'/modules/'.$modules[$i]->getVar('dirname').'/'.$sublink['url']);
}else{
$block['modules'][$i]['sublinks'][] = array('current' => 0, 'name' => $sublink['name'], 'url' => XOOPS_URL.'/modules/'.$modules[$i]->getVar('dirname').'/'.$sublink['url']);
}
}
} else {
$block['modules'][$i]['sublinks'] = array();
}
}
}

/* GPP No more changes to system_blocks.php
Other files that are affected:
Changes required to system_block_mainmenu.html
Changes optional to xoops.css to indicate the current menu choice.
*/
return $block;
}



system_block_mainmenu.html:
<table cellspacing="0">
<tr>
<td id="mainmenu">
<!-- GP debug tag II -->
<!--
<a class="menuTop" href="<{$xoops_url}>/"><{$block.lang_home}></a>
-->
<!-- start module menu loop -->
<{foreach item=module from=$block.modules}>
<{if ( $module.current == 1 )}>
<a class="menuMainAct" href="<{$xoops_url}><{$module.directory}>/">
<{else}>
<a class="menuMain" href="<{$xoops_url}><{$module.directory}>/">
<{/if}>
<{$module.name}>
</a>
<{foreach item=sublink from=$module.sublinks}>
<{if ( $sublink.current == 1 )}>
<a class="menuSubAct" href="<{$sublink.url}>">
<{$sublink.name}>
</a>
<{else}>
<a class="menuSub" href="<{$sublink.url}>">
<{$sublink.name}>
</a>
<{/if}>
<{/foreach}>
<{/foreach}>
<!-- end module menu loop -->
</td>
</tr>
</table>

xoops.css:
#mainmenu a {text-align:left; display: block; margin: 0; padding: 4px;}
#mainmenu a.menuTop {padding-left: 2px;}
#mainmenu a.menuMain {padding-left: 4px; font-weight: normal; background-color: #FFFFFF;}
#mainmenu a.menuMainAct {padding-left: 4px; font-weight: bold; background-color: #E0E0E0;}
#mainmenu a.menuSub {padding-left: 10px; font-weight: normal; background-color: #E0E0E0;}
#mainmenu a.menuSubAct {padding-left: 10px; font-weight: bold; background-color: #C0C0C0;}


Thanks - Grant.



3
gppetersen
Re: batch upload to weblinks
  • 2004/11/23 2:19

  • gppetersen

  • Just popping in

  • Posts: 3

  • Since: 2004/11/23


I'm going to have to do some importing myself so I had a look at this.
The MySQL utils that come with MySql can be used. I have shell access, you'll need this too if you do this.

The idea is to dump the db to a text file then use that as an example to create a text file of sql commands.
This can then be used by the MySQL utils to import the links. It wasn't too hard.

In the XOOPS admin, Activate the links, set up the Categories and add a link for an example.

Now get the DB into a text file:
mysqldump [-hhostname if not local] -uuser -ppassword XOOPS > xoops.sql
Assuming the XOOPS db is called xoops, and your MySQL user name is user with a password of password. This will dump ALL of the XOOPS DB to xoops.sql as ascii text.

You'll see your example links in this file.
Have a look at section under
-- Dumping data for table `xoops_mylinks_cat`
to find the number for each link group like this
INSERT INTO xoops_mylinks_cat VALUES (1,0,'News','http://');
in the above link the number for the News cat' is 1. It is a sub'cat' of cat 0, I guess that 0 is top cat'.

You'll need to note the number if you want catogories, other wise just make one general one and add them all to that. The cat number should be 1.

Heres a line I just imported:
----sql-start---
use xoops;

INSERT INTO xoops_mylinks_links VALUES (2,1,'boingboing','http://boingboing.net','',1,1,1101166311,1,0.0000,0,0);
INSERT INTO xoops_mylinks_text VALUES (2,'Boing boing: Interesting things.');
----sql-end----


There are two lines for each link
The first number must increment for the next link eg:
INSERT INTO xoops_mylinks_links VALUES (3,1,'Slashdot','ht..
INSERT INTO xoops_mylinks_text VALUES (3,'Slashdot: tech news

The second number is the Category. I've left all mine as 1, the news Category.

Other then that, change the name and the url in the first line and the description in the second.

save this file as new-links.sql then import them:
mysql -uuser -ppassword XOOPS < new-links.sql




TopTop



Login

Who's Online

115 user(s) are online (82 user(s) are browsing Support Forums)


Members: 0


Guests: 115


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits