Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
StefanL
New Member
New Member


Joined: Sep 20, 2003
Posts: 5

PostPosted: Wed Sep 24, 2003 1:50 pm Reply with quote

I have done some 'cosmetic' changes in Raven's 'Site Navigation Block'. Changes:
    * Added closing '</OPTION>' tags.
    * In Admin mode, you will now not get any error pages when you click on '--------', 'Invisible Modules' and 'Inactive Modules'.

Find in block-Modules.php:
Code:
    /* Now we make the Modules block with the correspondent links */

   $content .= "<SELECT NAME=\"name\" SIZE=\"8\" onChange=\"top.location.href=this.options[this.selectedIndex].value\">";
   $content .= "<OPTION VALUE=\"index.php\"><big>&middot;</big>&nbsp;"._HOME;
//    $content .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"index.php\">"._HOME."</a><br>\n";
    $sql = "SELECT title, custom_title, view FROM ".$prefix."_modules WHERE active='1' AND title!='$def_module' AND inmenu='1' ORDER BY custom_title ASC";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
   $m_title = $row[title];
   $custom_title = $row[custom_title];
   $view = $row[view];
   $m_title2 = ereg_replace("_", " ", $m_title);
   if ($custom_title != "") {
       $m_title2 = $custom_title;
   }
   if ($m_title != $main_module) {
       if ((is_admin($admin) AND $view == 2) OR $view != 2) {
         $content .= "<OPTION VALUE=\"modules.php?name=$m_title\"><big>&middot;</big>&nbsp;$m_title2";
//      $content .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"modules.php?name=$m_title\">$m_title2</a><br>\n";
       }
   }
    }

    /* If you're Admin you and only you can see Inactive modules and test it */
    /* If you copied a new module is the /modules/ directory, it will be added to the database */

    if (is_admin($admin)) {
   $handle=opendir('modules');
   while ($file = readdir($handle)) {
       if ( (!ereg("[.]",$file)) ) {
      $modlist .= "$file ";
       }
   }
   closedir($handle);
   $modlist = explode(" ", $modlist);
   sort($modlist);
   for ($i=0; $i < sizeof($modlist); $i++) {
       if($modlist[$i] != "") {
      $sql = "SELECT mid FROM ".$prefix."_modules WHERE title='$modlist[$i]'";
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);
      $mid = $row[mid];
      if ($mid == "") {
          $db->sql_query("INSERT INTO ".$prefix."_modules VALUES (NULL, '$modlist[$i]', '$modlist[$i]', '0', '0', '1')");
      }
       }
   }
   $content .= "<option>--------<option>"._INVISIBLEMODULES;
//   $content .= "<option><font class=\"tiny\">"._ACTIVEBUTNOTSEE."</font>";
   $sql = "SELECT title, custom_title FROM ".$prefix."_modules WHERE active='1' AND inmenu='0' ORDER BY title ASC";
   $result = $db->sql_query($sql);
   while ($row = $db->sql_fetchrow($result)) {
       $mn_title = $row[title];
       $custom_title = $row[custom_title];
       $mn_title2 = ereg_replace("_", " ", $mn_title);
       if ($custom_title != "") {
      $mn_title2 = $custom_title;
       }
       if ($mn_title2 != "") {
      $content .= "<OPTION VALUE=\"modules.php?name=$mn_title\"><big>&middot;</big>&nbsp;$mn_title2";
      $dummy = 1;
       } else {
      $a = 1;
       }
   }

   if ($a == 1 AND $dummy != 1) {
           $content .= "<strong><big>&middot;</big></strong>&nbsp;<i>"._NONE."</i><br>\n";
   }
   $content .= "<option>--------<option>"._NOACTIVEMODULES;
//   $content .= "<font class=\"tiny\">"._FORADMINTESTS."</font></center><br>";
   $sql = "SELECT title, custom_title FROM ".$prefix."_modules WHERE active='0' ORDER BY title ASC";
   $result = $db->sql_query($sql);
   while ($row = $db->sql_fetchrow($result)) {
       $mn_title = $row[title];
       $custom_title = $row[custom_title];
       $mn_title2 = ereg_replace("_", " ", $mn_title);
       if ($custom_title != "") {
      $mn_title2 = $custom_title;
       }
       if ($mn_title2 != "") {
      $content .= "<OPTION VALUE=\"modules.php?name=$mn_title\"><big>&middot;</big>&nbsp;$mn_title2";
      $dummy = 1;
       } else {
      $a = 1;
       }
   }
   $content .= "</select>";
   if ($a == 1 AND $dummy != 1) {
           $content .= "<strong><big>&middot;</big></strong>&nbsp;<i>"._NONE."</i><br>\n";
   }
    }

?>


Replace it with:

Code:
    /* Now we make the Modules block with the correspondent links */

   $content .= "<script language=\"JavaScript\">function gotoURL(dropDown) {   URL=dropDown.options[dropDown.selectedIndex].value;      if(URL.length>0) {         top.location.href = URL;       } } </script>";
   $content .= "<SELECT NAME=\"name\" SIZE=\"8\" onChange=\"gotoURL(this)\">";
//   $content .= "<SELECT NAME=\"name\" SIZE=\"8\" onChange=\"top.location.href=this.options[this.selectedIndex].value\">";
   $content .= "<OPTION VALUE=\"index.php\"><big>&middot;</big>&nbsp;"._HOME."</OPTION>";
//    $content .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"index.php\">"._HOME."</a><br>\n";
    $sql = "SELECT title, custom_title, view FROM ".$prefix."_modules WHERE active='1' AND title!='$def_module' AND inmenu='1' ORDER BY custom_title ASC";
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
   $m_title = $row[title];
   $custom_title = $row[custom_title];
   $view = $row[view];
   $m_title2 = ereg_replace("_", " ", $m_title);
   if ($custom_title != "") {
       $m_title2 = $custom_title;
   }
   if ($m_title != $main_module) {
       if ((is_admin($admin) AND $view == 2) OR $view != 2) {
         $content .= "<OPTION VALUE=\"modules.php?name=$m_title\"><big>&middot;</big>&nbsp;$m_title2</OPTION>";
//      $content .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"modules.php?name=$m_title\">$m_title2</a><br>\n";
       }
   }
    }

    /* If you're Admin you and only you can see Inactive modules and test it */
    /* If you copied a new module is the /modules/ directory, it will be added to the database */

    if (is_admin($admin)) {
   $handle=opendir('modules');
   while ($file = readdir($handle)) {
       if ( (!ereg("[.]",$file)) ) {
      $modlist .= "$file ";
       }
   }
   closedir($handle);
   $modlist = explode(" ", $modlist);
   sort($modlist);
   for ($i=0; $i < sizeof($modlist); $i++) {
       if($modlist[$i] != "") {
      $sql = "SELECT mid FROM ".$prefix."_modules WHERE title='$modlist[$i]'";
      $result = $db->sql_query($sql);
      $row = $db->sql_fetchrow($result);

      $mid = $row[mid];
      if ($mid == "") {
          $db->sql_query("INSERT INTO ".$prefix."_modules VALUES (NULL, '$modlist[$i]', '$modlist[$i]', '0', '0', '1')");
      }
       }
   }
   $content .= "<OPTION VALUE=\"\">--------</OPTION><OPTION VALUE=\"\">"._INVISIBLEMODULES."</OPTION>";
//   $content .= "<option><font class=\"tiny\">"._ACTIVEBUTNOTSEE."</font>";
   $sql = "SELECT title, custom_title FROM ".$prefix."_modules WHERE active='1' AND inmenu='0' ORDER BY title ASC";
   $result = $db->sql_query($sql);
   while ($row = $db->sql_fetchrow($result)) {
       $mn_title = $row[title];
       $custom_title = $row[custom_title];
       $mn_title2 = ereg_replace("_", " ", $mn_title);
       if ($custom_title != "") {
      $mn_title2 = $custom_title;
       }
       if ($mn_title2 != "") {
      $content .= "<OPTION VALUE=\"modules.php?name=$mn_title\"><big>&middot;</big>&nbsp;$mn_title2";
      $dummy = 1;
       } else {
      $a = 1;
       }
   }

   if ($a == 1 AND $dummy != 1) {
           $content .= "<strong><big>&middot;</big></strong>&nbsp;<i>"._NONE."</i><br>\n";
   }
   $content .= "<OPTION VALUE=\"\">--------</OPTION><OPTION VALUE=\"\">"._NOACTIVEMODULES."</OPTION>";
//   $content .= "<font class=\"tiny\">"._FORADMINTESTS."</font></center><br>";
   $sql = "SELECT title, custom_title FROM ".$prefix."_modules WHERE active='0' ORDER BY title ASC";
   $result = $db->sql_query($sql);
   while ($row = $db->sql_fetchrow($result)) {
       $mn_title = $row[title];
       $custom_title = $row[custom_title];
       $mn_title2 = ereg_replace("_", " ", $mn_title);
       if ($custom_title != "") {
      $mn_title2 = $custom_title;
       }
       if ($mn_title2 != "") {
      $content .= "<OPTION VALUE=\"modules.php?name=$mn_title\"><big>&middot;</big>&nbsp;$mn_title2";
      $dummy = 1;
       } else {
      $a = 1;
       }

   }
   $content .= "</select>";
   if ($a == 1 AND $dummy != 1) {
           $content .= "<strong><big>&middot;</big></strong>&nbsp;<i>"._NONE."</i><br>\n";
   }
    }

?>
 
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17077

PostPosted: Wed Sep 24, 2003 3:52 pm Reply with quote

Very nice indeed! I can't tell you how long ago I made that, but I quickly hacked it for my own use and then people started asking for it to the point that I just zipped it and made it availavle. Thanks! I will get this out ASAP.
 
View user's profile Send private message
telli
New Member
New Member


Joined: Sep 24, 2003
Posts: 21

PostPosted: Wed Sep 24, 2003 5:54 pm Reply with quote

Very nice i made a similar one but my coding isnt as neat. Wish i had known someone else had one. Btw nice site raven!

Telli

Only registered users can see links on this board! Get registered or login!
Image[/img]
 
View user's profile Send private message Visit poster's website
Raven
PostPosted: Wed Sep 24, 2003 6:30 pm Reply with quote

telli,

Thanks and right back at ya! I really like your use of the Blacks, blues, and greys!
 
StefanL
PostPosted: Thu Sep 25, 2003 7:26 am Reply with quote

telli wrote:
Very nice

Raven wrote:
Thanks! I will get this out ASAP.


Thank you both! One more tip would be to rename the file to something like 'block-myMenu.php' and then register it under 'Block' in Admin. This will leave the original file intact.

Raven wrote:
I can't tell you how long ago I made that, but I quickly hacked it for my own use and then people started asking for it to the point that I just zipped it and made it availavle.


I know this too well! Very Happy
 
Raven
PostPosted: Thu Sep 25, 2003 7:29 am Reply with quote

StephanL wrote:
One more tip would be to rename the file to something like 'block-myMenu.php' and then register it under 'Block' in Admin. This will leave the original file intact.
The user can do that Wink
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©