Trouble putting a Joomla 3.4 menu in Wordpress Theme - Joomla! Forum - community, help and support
hi all,
i'm working script else posted creating joomla menu in wordpress theme without using wordpress joomla. have site we're creating want use wordpress our blogging platform , joomla our main site. wordpress location /blog in our main directory. , our goal have menu in wordpress site automatically update if changes in joomla site.
i've started last script person posted here:
viewtopic.php?f=615&t=712347#p2799224
this works great , figured out how have script go 2 levels deep (which need in case) how have script assign appropriate classes navbar , drop down menu links. it's bit different main site's code, it's working.
but have 2 problems can't wrap head around.
problem 1 how have script not assign drop down class if there isn't child menu item - or visa versa, assign drop down class if there child. i'm not sure how test see if there child , if so, include drop down class, else no class. right now, have 4 links children (sub links in drop down each of 4 links) , 1 link no drop down. script right showing empty drop down 1 link no sub links.
problem 2 , assume more difficult of two, ordering of drop down links wrong, aren't in same order main joomla site. looks drop down ordered according id number in wordpress site i'm trying have menu show up, isn't case in joomla site. not sure call use make ordering correct.
any thoughts anyone? i'm not great php, can enough me in trouble :-)
any appreciated...
below code have...
thanks!
i'm working script else posted creating joomla menu in wordpress theme without using wordpress joomla. have site we're creating want use wordpress our blogging platform , joomla our main site. wordpress location /blog in our main directory. , our goal have menu in wordpress site automatically update if changes in joomla site.
i've started last script person posted here:
viewtopic.php?f=615&t=712347#p2799224
this works great , figured out how have script go 2 levels deep (which need in case) how have script assign appropriate classes navbar , drop down menu links. it's bit different main site's code, it's working.
but have 2 problems can't wrap head around.
problem 1 how have script not assign drop down class if there isn't child menu item - or visa versa, assign drop down class if there child. i'm not sure how test see if there child , if so, include drop down class, else no class. right now, have 4 links children (sub links in drop down each of 4 links) , 1 link no drop down. script right showing empty drop down 1 link no sub links.
problem 2 , assume more difficult of two, ordering of drop down links wrong, aren't in same order main joomla site. looks drop down ordered according id number in wordpress site i'm trying have menu show up, isn't case in joomla site. not sure call use make ordering correct.
any thoughts anyone? i'm not great php, can enough me in trouble :-)
any appreciated...
below code have...
thanks!
code: select all
<?php // creating joomla menu http://forum.joomla.org/viewtopic.php?f=615&t=712347
function jtoplevelmenu($menu){
$host = 'localhost'; //host of database
$user = ''; //user name database
$pass = ''; //password database
$db = ''; //databse name
$prefix = ''; //joomla table prefix
$menutyoe = $menu; //title of menu wish grab
$con = mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db);
$result = mysql_query("select * ".$prefix."menu menutype='".$menutyoe."' && published='1' && parent_id='1'");
while($row = mysql_fetch_array($result)){
$id = $row['id'];
$name = $row['title'];
$link = $row['link'];
$accessrqd = $row['access'];
//if specific access required
if($accessrqd > 1){
//check if user logged
$uname = uloginchk();
if($uname > ''){
//logged in - check access
showorhide($accessrqd, $uname);
}
}
else{ //no specific access level required - display item
echo '<ul class="nav menu navbar-nav">';
echo '<li class="deeper parent dropdown">';
if($row['type'] == 'component'){
echo '<a class="dropdown-toggle" data-toggle="dropdown" href="../';
echo $link;
}else{
echo '<a href=".';
echo $row['link'];
}
if($row['browsernav'] > 0){
echo '" target="_blank"';
}else{
echo '" target="_parent">';
}
echo $name;
echo '<span class="caret"></span>';
echo '</a>';
if(jsubmenu($row['id'],$prefix,$menutyoe, $subnav) != ''){
echo jsubmenu($row['id']);
}
echo '</li>';
echo '</ul>';
}
}
}
function jsubmenu($id,$prefix,$menutyoe){
$result = mysql_query("select * ".$prefix."menu menutype ='".$menutyoe."' && parent_id='".$id."' && published='1'");
echo '<ul class="nav-child unstyled small dropdown-menu">';
while($row = mysql_fetch_array($result)){
$id = $row['id'];
$name = $row['title'];
$link = $row['link'];
$accessrqd = $row['access'];
//if specific access required
if($accessrqd > 1){
//check if user logged
$uname = uloginchk();
if($uname > ''){
//logged in - check access
if(showorhide($accessrqd, $uname,$prefix)){
echo '<li>';
if($row['type'] == 'component'){
echo '<a href="../';
echo $link;
}else{
echo '<a href=".';
echo $row['link'];
}
if($row['browsernav'] == 1){echo '" target="_blank">';}
else{echo '" target="_parent">';}
echo $name;
echo '</a>';
echo '</li>';
}
}
}
else{ //no specific access level required - display item
echo '<li>';
if($row['type'] == 'component'){
echo '<a href="../';
echo $link;
}else{
echo '<a href=".';
echo $row['link'];
}
if($row['browsernav'] == 1){echo '" target="_blank">';}
else{echo '" target="_parent">';}
echo $name;
echo '</a>';
echo '</li>';
}
}
echo '</ul>';
}?>
actually second problem easier, cant sure, sql query can have order field
mysql_query("select * ".$prefix."menu menutype ='".$menutyoe."' && parent_id='".$id."' && published='1' order '".$id."');
choosing leaf selector in css difficult without jquery, jquery infifgicent solution , shouldnt necessary, because should able create different class li elements parents in pho. without seeing entire structure of site not easy how rewrite php that.
the easiest way, if showing menu ancestry current item, identify whether itemid of menu itemid of page being displayed. then, unless itemid parent of current itemid, has no children. that's easy.
mysql_query("select * ".$prefix."menu menutype ='".$menutyoe."' && parent_id='".$id."' && published='1' order '".$id."');
choosing leaf selector in css difficult without jquery, jquery infifgicent solution , shouldnt necessary, because should able create different class li elements parents in pho. without seeing entire structure of site not easy how rewrite php that.
the easiest way, if showing menu ancestry current item, identify whether itemid of menu itemid of page being displayed. then, unless itemid parent of current itemid, has no children. that's easy.
Comments
Post a Comment