Author |
Message |
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm

Joined: Aug 13, 2009
Posts: 1123
|
Posted:
Mon Aug 15, 2011 3:04 pm |
|
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 |
|
|
 |
hicuxunicorniobestbuildpc

|
Posted:
Tue Aug 16, 2011 1:44 am |
|
Oh my god!, 23 people viewed this post and nobody answered yet. bump
 |
|
|
|
 |
spasticdonkey
RavenNuke(tm) Development Team

Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA
|
Posted:
Tue Aug 16, 2011 9:25 am |
|
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... |
|
|
|
 |
hicuxunicorniobestbuildpc

|
Posted:
Wed Aug 17, 2011 4:22 pm |
|
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
|
Posted:
Wed Aug 17, 2011 8:09 pm |
|
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 |
|
|
 |
hicuxunicorniobestbuildpc

|
Posted:
Thu Aug 18, 2011 5:37 am |
|
This is the original navigation menu. it is working fine with phpnuke but with Ravennuke doesnt work.
http://destroydrop.com/javascripts/tree/
What I have is an addon wich get connected with data base add links from admin control. |
|
|
|
 |
killing-hours

|
Posted:
Thu Aug 18, 2011 7:42 am |
|
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:
Download:
http://www.mediafire.com/?4nl0dmk8cgfm7rr |
|
|
|
 |
hicuxunicorniobestbuildpc

|
Posted:
Thu Aug 18, 2011 4:04 pm |
|
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

|
Posted:
Thu Aug 18, 2011 8:15 pm |
|
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. |
|
|
|
 |
|