1
Diabl0
Dynamic Main Menu module sub options
  • 2004/8/3 5:49

  • Diabl0

  • Just popping in

  • Posts: 11

  • Since: 2004/7/3 1


After many many helping answers on this forum, my module is working, and now i'm working on extending it. Now i got 2 next questions:

I want add some custom menu positions to Mainmenu under my module for users that submited their datas (something like "Edit/View your submision". It's like in MyLinks or MyAlbum modules where there is option to add maincategories to main menu.

Seccond litle "less" question, is how to add submisions on my module to counts on userinfo page as another post, and show it under other links, photos, forum posts, news and so on?

Thanks in advance for help

2
hervet
Re: Dynamic Main Menu module sub options
  • 2004/8/4 19:07

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Hi,

In your xoops_version.php file, add this kind of line :

$modversion['sub'][$i]['name'] = "name of the sub menu";
$modversion['sub'][$i]['url'] = "url_to_the_page";

Bye,
Hervé

3
Diabl0
Re: Dynamic Main Menu module sub options
  • 2004/8/5 6:12

  • Diabl0

  • Just popping in

  • Posts: 11

  • Since: 2004/7/3 1


Hi Harvet

Unfortunently, you don't understand me. I know about $modversion['sub'] in xoops_version.php (and i use it too), but i'm looking for solution to add some submenu position from inside module source, depending on some database values.

Exactly in this case, i want to add something like "Your submisions" submenu depending on whatewer user has submited some infos stored in database and marked with his uid.

Something like:

Quote:

$result = $xoopsDB->query( "select COUNT(uid) AS il_n from ".$xoopsDB->prefix("noclegi")." WHERE uid=".$XoopsUser->getVar('uid') );
$row = $xoopsDB->fetchArray( $result);
if ($row['il_n']>0) {
// Add submenu "Your submisions"
}


4
Mithrandir
Re: Dynamic Main Menu module sub options

in xoops_version.php
global $xoopsModule$xoopsDB$xoopsUser;
if (
$xoopsModule->getVar('dirname') == 'dirname_of_your_module') {
 
$result $xoopsDB->query"select COUNT(uid) AS il_n from ".$xoopsDB->prefix("noclegi")." WHERE uid=".$xoopsUser->getVar('uid') );
$row $xoopsDB->fetchArray$result);
 if (
$row['il_n']>0) {
   
// Add submenu "Your submisions"
 
}
}

5
wammes
Re: Dynamic Main Menu module sub options
  • 2004/12/21 15:07

  • wammes

  • Not too shy to talk

  • Posts: 101

  • Since: 2002/1/3 1


Nice, I was looking for this kind of functionality. I saw the edito module adding for each page a new link to the main menu with this code:
global $xoopsDB$xoopsUser$xoopsModuleConfig;
include_once (
XOOPS_ROOT_PATH "/modules/edito/include/functions_block.php");
$modversion['hasMain'] = 1;
$subcount ;
$group is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
$sublinks $xoopsDB->query"SELECT Id_edito, subject, groups 
FROM "
.$xoopsDB->prefix("edito").
WHERE offline = 1 AND contents_nomain = 1
ORDER BY "
.edito_getmoduleoption('order')."") ;
if( 
$sublinks != false
{
    while(list( 
$Id_edito $subject $groups ) = $xoopsDB->fetchRow$sublinks )) 
    {
//    $groups = explode(" ",$sublinks['groups']);
    
$groups explode(" ",$groups);

        if (
count(array_intersect($group,$groups)) > 0)
        {
            
$modversion['sub'][$subcount]['name'] = $subject ;
            
$modversion['sub'][$subcount]['url'] = "edito.php?idedito=".$Id_edito."" ;
            
$subcount++ ;
        }
    }
}


So this means xoops_version.php is evaluated every time a page loads? Or should I call another function into my module code to update the main menu with the new xoops_version.php query results.

Thanks in advance!

6
Mithrandir
Re: Dynamic Main Menu module sub options

Not every time the page loads - but every time any page loads the xoops_version.php... such as the main menu block.

That is why, in my code I have a check to see, whether we are actually in the module of the xoops_version.php

A better implementation of the check is:
if (isset($_GLOBALS['xoopsModule']) && $_GLOBALS['xoopsModule']->getVar('dirname') == $modversion['dirname']) {
    
//add sub menus
}

7
wammes
Re: Dynamic Main Menu module sub options
  • 2004/12/21 16:02

  • wammes

  • Not too shy to talk

  • Posts: 101

  • Since: 2002/1/3 1


Aaah, I think I'm getting it. Still new to php coding .

I'll try and see if it works. Thanks!

8
hervet
Re: Dynamic Main Menu module sub options
  • 2004/12/21 17:14

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Quote:

wammes wrote:
Aaah, I think I'm getting it. Still new to php coding .

It's a XOOPS tips, not a php tips.

Login

Who's Online

123 user(s) are online (74 user(s) are browsing Support Forums)


Members: 0


Guests: 123


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