Jump to content

Recommended Posts

Hey Guys,

Haven't been able to find help so far so I thought I'd give this forum a try.

 

So basically I'm trying to center the submenus this plugin creates for wordpress.

The plugin is: "WP Menu Creator" http://wordpress.org/extend/plugins/wp-menu-creator/

 

Here is a Snippet the PHP Generates:

 

<li id="menu_item_5" class="mc_menu_item external_link ">
<a class="change_section panel submenu" rel="" title="5" href="http://localhost/">Main Menu Title</a>
<ul id="mc_submenu_5" class="mc_menu mc_depth_1">
<li id="menu_item_18" class="mc_menu_item external_link ">
<a class="change_section panel " rel="" title="5" href="http://localhost/">Submenu Title 1</a>
</li>
<li id="menu_item_20" class="mc_menu_item external_link ">
<a class="change_section panel " rel="" title="5" href="http://localhost/">Submenu Title 3</a>
</li>
<li id="menu_item_21" class="mc_menu_item external_link ">
<a class="change_section panel " rel="" title="5" href="http://localhost/">Submenu Title 4</a>
</li>
</ul>
</li>

 

And Here is the code that 'writes' this up:

function displayMenuFromItems($items, $depth, $parent, $ismenu) {
if ($items) :
	echo "\n".'<ul id="' . ($ismenu ? "menu" : "mc_submenu_" . $parent) . '" class="mc_menu mc_depth_' . $depth . '">'."\n";
	foreach ($items as $item) :
	$class="";
	if ($item["type"] == "wordpress") {
		if (is_page($item["value"])) {
			$class="current_page_item";
		}
	} else {
		if (curPageURL() == $item["value"] || curPageURL() == $item["value"] . "/") {
			$class="current_page_item";
		}
	}
		$pos = strpos(pageURL(),'#');
		/*if(isset($_GET['cat']) || isset($_GET['p']) || isset($_GET['m']) || isset($_GET['author']) || $pos != false) {
			$urlAddon = 'index.php';
		} else {
			$urlAddon = '';
		}*/

		if(!isset($_GET['cat']) && !isset($_GET['p']) && !isset($_GET['m']) && !isset($_GET['author']) && ($pos != false || pageURL() == get_bloginfo('url').'/') || pageURL() == get_bloginfo('url')) {
			$findHash = strpos($item['value'], '#');
			if ($findHash != false) {
				$item['value'] = substr($item['value'], $findHash);
			}
			}
	echo '<li id="menu_item_' . $item["id"] . '" class="mc_menu_item ' . ($item["type"] == "wordpress" ? "wordpress_link" : "external_link") . ' ' . $class . '"><a href="' . $urlAddon. resolveURL($item) . '" title="' . ($ismenu ? $item["id"] : $parent) . '" rel="' . $item["target"] . '" class="change_section panel '. (count($item["subitems"]) > 0 ? 'submenu' : '') .'">' . $item["title"] . '</a>';
		if ($depth>0) displayMenuFromItems($item["subitems"], $depth-1, $item["id"], false);
	echo '</li>'."\n";

	endforeach;
	echo '</ul>'."\n";
endif;

 

I've tried placing <div>'s in between various to try and wrap/single out the submenu(to style it centered) but as you can see the <div>'s end up eventually wrapping the main menu.

 

I'm all out of ideas on workarounds without advanced PHP knowledge, so if there is anyone out there that can help me or point me into the right direction it will be much appreciated!

 

The site I'm working on is: http://jpatrolla.com/x (test site)

and you will be able to see which submenu's I'm trying to center under 'Blog' and 'Portfolio'

 

Thanks in Advance.

-Joe

Link to comment
https://forums.phpfreaks.com/topic/250930-wordpress-menu-creator/
Share on other sites

Cheers for the quick reply Goth,

 

I'm quite good at CSS, unordered and ordered lists (ul, li) are pretty much impossible (unless my research has failed me) to center.

My workaround is trying to wrap the submenu in a div and then centering that but my PHP knowledge is basic at its best.

 

Thanks for the Contact button heads up, I've just been testing on FireFox and have just sussed it out on Chrome, will fix that now.

 

 

I don't know much about CSS and designing tho (I hate designing to be honest) I'm more into php and such

but I've checked online for your problem, and as I understand it's purely CSS, here is a link to someone talking about sub menus like yours, and in their CSS, you'll see the float position is left, perhaps if you changed that to center it would do what you want.

 

BTW, I'm not giving a solution, I'm a total idiot when it comes to designing and positions, I'm just trying to give you an idea that my lead you to the solution

 

http://www.sohtanaka.com/web-design/horizontal-sub-nav-with-css-jquery/

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.