Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks
Author Message
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm



Joined: Aug 13, 2009
Posts: 1084

PostPosted: Mon Aug 15, 2011 3:04 pm Reply with quote

Hi Guys!

I've been searching here how to convert a block to make it work for Ravennuke but unfortunatly I coudn't find anything but I see examples how actually you can load javascript and css with rn2.40.01. Those examples helped me with the first part but not at all. I don't get it work yet. I am a little bit lost.

The block

Code:
global $db, $content, $prefix;


//$content .= '<link rel="StyleSheet" href="blocks/wsnavlinks/dtree.css" type="text/css" />';
//$content .= '<script type="text/javascript" src="blocks/wsnavlinks/dtree.js"></script>';

$content .= '<link rel="StyleSheet" href="blocks/bbnavlinks/dtree.css" type="text/css" />';
$content .= '<script type="text/javascript" src="blocks/bbnavlinks/dtree.js"></script>';


$content .="<div class=\"dtree\">

   <script type=\"text/javascript\">
      <!--

      d = new dTree('d');";
$content .="d.add(0,-1,'Main Menu');";
$sql = sprintf("SELECT * FROM %s_bb_nav_links WHERE sub <1 ORDER BY main_order ASC",
                $prefix);
      $result = $db->sql_query($sql);
      $num = $db->sql_numrows($result);
      for($r =0; $r <$num; $r++){      
   $row = $db->sql_fetchrow($result);
   $k = $r+1;
   if($row['link_url'] !=''){
$content .="d.add(".$k.",0,'".$row['link_name']."', '".$row['link_url']."', '".$row['link_desc']."');";
}else{
$content .="d.add(".$k.",0,'".$row['link_name']."', '', '".$row['link_desc']."');";
}


$sql2 = sprintf("SELECT link_desc, link_name, link_url FROM %s_bb_nav_links WHERE sub='%d' ORDER BY sub_order ASC",
                $prefix, $row['lid']);
      $result2 = $db->sql_query($sql2);
      $num2 = $db->sql_numrows($result2);
   if($num2 >0){
      
for($t =0; $t <$num2; $t++){
$y = $t+1;
$u = $num+$y;
$row2 = $db->sql_fetchrow($result2);
$content .="d.add(".$u.",".$k.",'".$row2['link_name']."','".$row2['link_url']."', '".$row2['link_desc']."');";

}

}

}
$content .="document.write(d);

      //-->
   </script>

</div>";



Like this is not working and I don't know why.

I tried to convert it begining like this.

I create a file head-Navigation.php

in folder includes/addon/


Code:
<?php


if (stristr(htmlentities($_SERVER['PHP_SELF']), 'head-Navigation.php')) {
   Header('Location: ../../index.php');
   die();
}
   addCSSToHead('blocks/bbnavlinks/dtree.css', 'file');
   addJSToHead('blocks/bbnavlinks/dtree.js', 'file');

?>



I commented out

Code:
//$content .= '<link rel="StyleSheet" href="blocks/bbnavlinks/dtree.css" type="text/css" />';

//$content .= '<script type="text/javascript" src="blocks/bbnavlinks/dtree.js"></script>';


From the original block but I can not make it work. Please I will be appriciate if someone can give some details how to create a block to work properly in RavenNuke. Thanks in advance.


Last edited by hicuxunicorniobestbuildpc on Wed Aug 17, 2011 4:41 pm; edited 1 time in total 
View user's profile Send private message
hicuxunicorniobestbuildpc







PostPosted: Tue Aug 16, 2011 1:44 am Reply with quote

Oh my god!, 23 people viewed this post and nobody answered yet. bump Shocked

Sad
 
spasticdonkey
RavenNuke(tm) Development Team



Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA

PostPosted: Tue Aug 16, 2011 9:25 am Reply with quote

you were right to load css within a head-xxxx.php file, as you cannot load css from within a block.. Loading the JS file there is fine too, or you could try adding it to the bodyJS array (some JS scripts require being in the head of the document, others do not)

This would work within a block if the JS script supports loading in the body.
Code:
addJSToBody('blocks/bbnavlinks/dtree.js', 'file');

$inlineJS = '<script type="text/javascript">
your script here
</script>';
addJSToBody($inlineJS, 'inline');


A little hard to see what is exactly going on with the JS you are creating. I would first verify you are getting proper results from your db queries. If you look at the html source generated does it look correct? If not, try removing the JS from the block and just displaying the results and get that working first...
 
View user's profile Send private message Visit poster's website
hicuxunicorniobestbuildpc







PostPosted: Wed Aug 17, 2011 4:22 pm Reply with quote

Thanks for at least answer this post. I think this is difficult to understand. It should be a good video tutorial o more examples how to use the new feauture from Ravennuke. I am completely lost with this.

This is the javascript. How can I convert it since it has $content already as a block. Explain with more details please. thanks.

Code:
      <!--


      d = new dTree('d');";
$content .="d.add(0,-1,'Main Menu');";
$sql = sprintf("SELECT * FROM %s_bb_nav_links WHERE sub <1 ORDER BY main_order ASC",
                $prefix);
      $result = $db->sql_query($sql);
      $num = $db->sql_numrows($result);
      for($r =0; $r <$num; $r++){      
   $row = $db->sql_fetchrow($result);
   $k = $r+1;
   if($row['link_url'] !=''){
$content .="d.add(".$k.",0,'".$row['link_name']."', '".$row['link_url']."', '".$row['link_desc']."');";
}else{
$content .="d.add(".$k.",0,'".$row['link_name']."', '', '".$row['link_desc']."');";
}


$sql2 = sprintf("SELECT link_desc, link_name, link_url FROM %s_bb_nav_links WHERE sub='%d' ORDER BY sub_order ASC",
                $prefix, $row['lid']);
      $result2 = $db->sql_query($sql2);
      $num2 = $db->sql_numrows($result2);
   if($num2 >0){
      
for($t =0; $t <$num2; $t++){
$y = $t+1;
$u = $num+$y;
$row2 = $db->sql_fetchrow($result2);
$content .="d.add(".$u.",".$k.",'".$row2['link_name']."','".$row2['link_url']."', '".$row2['link_desc']."');";

}

}

}
$content .="document.write(d);

      //-->
 
killing-hours
RavenNuke(tm) Development Team



Joined: Oct 01, 2010
Posts: 438
Location: Houston, Tx

PostPosted: Wed Aug 17, 2011 8:09 pm Reply with quote

unicornio wrote:
I think this is difficult to understand.


Quite the understatement. Where did this block come from and where can I see it in action as it was intended? To me... it looks extremely sloppy and very hard to understand what the intentions are behind the coding.

If this is nothing more than a navigation menu... seems it would be better done differently IMO.

_________________
Money is the measurement of time - Me
"You can all go to hell…I’m going to Texas" -Davy Crockett 
View user's profile Send private message
hicuxunicorniobestbuildpc







PostPosted: Thu Aug 18, 2011 5:37 am Reply with quote

This is the original navigation menu. it is working fine with phpnuke but with Ravennuke doesnt work.
[ Only registered users can see links on this board! Get registered or login! ]

What I have is an addon wich get connected with data base add links from admin control.
 
killing-hours







PostPosted: Thu Aug 18, 2011 7:42 am Reply with quote

Knock yourself out. Here is the example file they had on their site, slightly modified to work with Ravennuke.

*** I modified the "dtree.js" file to fix image linking.


Screenshot of proof:
Image

Download: [ Only registered users can see links on this board! Get registered or login! ]
 
hicuxunicorniobestbuildpc







PostPosted: Thu Aug 18, 2011 4:04 pm Reply with quote

Thanks for taking the time but I guess It is better I sent the whole block to u so u can see what is happening. Actually my block is working with database and u can control it from admin control panel. I will see what I can do..
 
killing-hours







PostPosted: Thu Aug 18, 2011 8:15 pm Reply with quote

That's quite alright. I honestly don't have the time to write your block for you. (currently re-writing my entire daily website & still need to get back to working on my media gallery)

Use that block as an example of how to get this to work... from there all you have to do is code your database functions and pass the variables to your tree structure the way you want it to show. That example is about 70% of the battle. All you should have to do is make it behave the way you want it to.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks

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 ©