Info
- 46 posts
- 6 voices
- Started 5 years ago by Null
- Latest reply from Null
- This topic is not a support question
Plugin: bbMenu 0.1 beta
-
- Posted 5 years ago #
Okay here it is, bbMenu 0.1 beta
What does it do?
It adds a menu to you bbPress site, which you can re-order yourself using drag and drop at the adminpage.I am releasing this beta in hope to get some help concerning these issues:
1) I need some "better" way to store/ get the page-id comparison from the database. Currently, the script compares the page-id with 'location' from the database table. It's only possible to add just 1 value to this, so if the page id = front-page it will return true and give the
<a>an id= current and the link will be underlined.The thing is, I need to add more stuff cause now only the front page is id-ed as current as the forum link is active, while topic-page should return as current aswell, cause I want this page to be "under" the forum link as well.
I've tried filling the location in the table like this: front-page || topic-page, but this will not work, cause the script will check front-page || topic-page = page-id instead of picking just one to see if it is the same as page-id.
Hope I do make any sense, just check the script.
2) In IE the underline doesn't show. It works in all other browsers, don't know why.
To do:
1) Use some hooks for the admin pages (need bbPress 0.80 to do this right)
2) Be able to click the menu title in the menu (in the admin) to change it into what ever you like
3) Some documentation so people (plugin builders) can add their own pages
4) Use scriptaculous instead of the scripts I use now (more options)Download the beta:
http://www.sourceskins.com/bbMenu-0.1.zip -
- Posted 5 years ago #
-
- Posted 5 years ago #
Nice
Btw stubled on the BLIX theme from bbPress. It uses for each (I asked about this in some other posts) in it's menu and could be the answer of my nr 1 problem.
Some peace of code:
foreach ($pages as $page) {
$page_id = $page->ID;
$page_title = $page->post_title;
$page_name = $page->post_name;
if ($page_name == "archives") {
(is_page($page_id) || is_archive() || is_search() || is_single())?$selected = ' class="selected"':$selected='';
echo "<li".$selected."><a href=\"".get_page_link($page_id)."\">Archives</a></li>n";
}
Now to confert it to this plugin, have to change 'location' input to: is_archive() || is_search() etc. Going to play with this :) -
- Posted 5 years ago #
Forgot to say this before, but this looks really sweet.
-
- Posted 5 years ago #
Got the for each working:
<ul id="navlist">
<?php $pages = get_bb_menu();
if ($pages) {
foreach ($pages as $page) {
$page_id = $page->page;
$page_item = $page->item;
$page_location = $page->location;
echo "<li><a href="".($page_id)."">".($page_item)."</a></li>n";
}
}
?>
</ul>The problem is, how can I let it spit:
<li><a <?php if (is_bb_search())
{
echo "id="current"";
}?> href="$page_id">$page_item</a></li>And
is_bb_search()is$page_location = $page->location; -
- Posted 5 years ago #
...only the front page is id-ed as current as the forum link is active, while topic-page should return as current aswell, cause I want this page to be "under" the forum link as well...
<grimace />
If you do that (a) your page won't validate and (b) there's no guarantee of how the browser will interpret the content because HTML4 and XHTML specs require that element ID is unique in a page.
From HTML4 spec:
"id ID #IMPLIED -- document-wide unique id --
class CDATA #IMPLIED -- space-separated list of classes --Yet another reason to use
class="current". Using classes and ID's appropriately is important. -
- Posted 5 years ago #
So, I think now you're getting the function name "is_bb_search" (among other function names) from the db and you want to execute it to know if a particular list item should be marked as current.
If that's the case then it's what I described before, which is something like where the function name is defined in
$rw["location"]so......
$page_location = $page->location;
$switch = eval("return ".$rw["location"]);
$current = ($switch ? ' class="current"' : "");
echo "<li $current><a href="$page_id">$page_item</a></li>";
... -
- Posted 5 years ago #
Yeah I know about the id/class thingy, but even WP uses id instead of class. So why do they do that?. Are they wrong too? Perhaps I will change it in the official release, I just want to have it working first :)
-
- Posted 5 years ago #
Syntactically speaking: only if a page does not validate is it "wrong".
Semantically speaking: if a page uses
idto encode semantic meaning then it is syntactically correct, but semantically naive (which for a "semantic personal publishing platform" is sub-optimal).There are possibly places where WP gets semantically wrong, but, a lot (possibly all) of this is down to theme and plugin designers who are often unaware of the semantic issues.
Anyhow, your description in the opening post (two items returning "current" as their id) is something that will create a non-validating document, so it would be syntactically wrong.
In summary:
idis for addressing elements,classis for describing them. -
- Posted 5 years ago #
But then I will have <li class= > and They wont conflict?
Btw the code you gave doesn't work. They beta is the most stable I've got working correctly. So if you like to help me out, plz take a look at it. And yes the beta has the "wrong" id coding.
-
- Posted 5 years ago #
I think your post may be corrupted: did you mean to say
<li class= >
? -
- Posted 5 years ago #
if something "doesn't work" then:
- if you have an error message, google it, it may be something trivial.
- if you can't understand what you see on google, post the error message here, so the magical community mind can see it - the key benefit of the forum is that one person's fix becomes a solution for every person who follows with similar problems.
-
- Posted 5 years ago #
Quote
I think your post may be corrupted: did you mean to say
<li class= >
?Yes it got corrupted,
<a class=>is what I ment.Btw to solve my 'problem' I am indeed going to use the switch thingy (read some more about it), so it will check some hardcoded "location" first and then check the db list. It's kinda an ugly workaround, but normal users wont be bothered with this code anyway...
Anyone has any ideas about the IE "bug" ??
-
- Posted 5 years ago #
Is there a demo of it somewhere? I have no need to install it, so I can't see the IE underline problem.
Does it have anything to do with the :hover pseudo class? That can only be applied to
<a>elements in IE before version 7. Not sure if that's what the problem is. A demo would be helpful for me to see it without installing it, if possible. -
- Posted 5 years ago #
Same problem in IE 7, no underline there either. It only effects IE as far as I know...
Got it running on my testsite:
http://www.sourceskins.com/bbpress/ -
- Posted 5 years ago #
Null, I looked at your site. No underlines appear for me with IE7 either, whether hovering or not. So, I don't think it's the :hover pseudo class problem (and especially since the :hover is applied to
<a>elements.It looks like the underline might be behind the #cleaner div in IE, where it's on top of it in FF. Can you try making the #wrapper-menu taller and see if you can see underlines then? I am guessing they are there, just not visible since they're behind the #cleaner div.
Is there a tool comparable to the web developer extension for FF, on IE? I installed the IE Developer toolbar, but it does not give you the ability to modify the CSS and see the changes.
-
- Posted 5 years ago #
Hi,
Thanks for the suggestion. I will look into this and take out the cleaner div and look at the page in IE again. If it's still not there, then it's not the div. I'll post my findings here as soon as I have tested this.
Thx
ps. I have no idea if there are any toolbars like FF, sorry.
-
- Posted 5 years ago #
Even without the cleaner div it's still not working in IE :(
So it's not the div...
-
- Posted 5 years ago #
The first google result for "IE7 border-bottom" gives the answer to this.
I got it to work in IE7 by...
- changing all references from
id="current"toclass="current"(because I refuse to write semantically wrong css :) ) - replacing
#currentwith.current { display: block; BORDER-BOTTOM: #2e6e15 3px solid; }
-
- Posted 5 years ago #
...... i have to work on my google search words :(
-
- Posted 5 years ago #
-double post-
-
- Posted 5 years ago #
That comes with bitter experience :)
Once it's working, it's then a good time start thinking about integration. Since this is a plugin it will have to work with many themes, so for maximum flexibility you might want to switch from pixel based sizing to either percentages or ems so that everything is sized relative to the default font.
-
- Posted 5 years ago #
Okay this IE fix works, but gives a little design problem. On mouseover the underline will appear, but this also effects the div it's in. Just look at the | between Forums | Search. Move with you mouse over Search (or click it) and see the | grow. Would like to keep the bar where the links are in the same size as it is now (looks great).
Any ideas?
-
- Posted 5 years ago #
that's because the underline changes the size of the anchor element. a simple solution is to create a transparent underline for the standard anchor element, then change the color when hovered.
-
- Posted 5 years ago #
Well the IE bug is solved, now I have the other one left.
Tried this:
$current = ('topic-page' == get_bb_location() || $rw['location'] == get_bb_location()) ? ' id="current"' : '';I've added
'topic-page' == get_bb_location() ||to it. It works partialy. If topic-page isn't get_bb_location then it wil use$rw['location'] == get_bb_location(), but if topic-page IS get_bb_location then it will underline ALL links. I think cause it doesn't know that it only needs to underline the Forums link. So how to fix this so when topic-page IS get_bb_location -> is current -> highlight ForumsThx
-
- Posted 5 years ago #
I think I answered this earlier ...
$switch = eval("return ".$rw["location"]);... because $rw["location"] is, I think, the name of a function which you're pulling from the DB.
-
- Posted 5 years ago #
Well the switch gives this error:
Parse error: parse error, unexpected $ in /xxx/bbpress/my-plugins/bbmenu.php(123) : eval()'d code on line 1Isn't there a simpler way? Like always underline Forum unless $rw['location'] == get_bb_location()
So if current isn't present in the li list, uinderline Forums. If this is possible, it would solve all problems :)
-
- Posted 5 years ago #
Can you confirm what I asked earlier about the content of $rw["location"]?
If that is what you're doing then modify this example:
<?php
function exampleOne() {
return "bb";
}
function exampleTwo() {
return "press";
}
$rw["one"] = "exampleOne";
$rw["two"] = "exampleTwo";
$switchOne = call_user_func($rw["one"]);
$switchTwo = call_user_func($rw["two"]);
echo($switchOne);
echo($switchTwo);
?>Obviously you don't need the example methods, but just use call_user_func on the name of the method you're pulling from the DB.
-
- Posted 5 years ago #
That is about right. I suggest you install the beta plugin and take a look, cause I am a noob and perhaps we are talking about the same, but in other words :)
I am also looking for alternitive solutions like:
Isn't there a simpler way? Like always underline Forum unless $rw['location'] == get_bb_location()So if current isn't present in the li list, uinderline Forums. If this is possible, it would solve all problems :)
And:
replacing/filtering bb_get_location so when it says: topic-page it will be filter to: front-page (and the forum link will be underlined.Well in theory... :)
-
- Posted 5 years ago #
Tip: you really need to stop repeating the errors that have been debugged for you.
You cannot do
$rw["location"] == get_bb_location()because you are comparing (on the left hand side of the==) the name of a function with (on the right hand side of the==) the result of a function.You could do:
if ( call_user_func($rw["location"]) == get_bb_location() ) {
// do something
}But that's probably not going to achieve what you're trying to do because it's going to depend on what the function actually does (whose name is stored in $rw["location"]) ... so if it returns a boolean value, then it's not going to work because
get_bb_location()returns a page name.Incidentally the whole idea of storing the name of the function in the database is slightly more black belt than "noob" territory. You'd be better off storing a flag in the DB then translating the flag into a function name in the your code, because it's more easily traced.
Isn't there a simpler way?
Probably - describe in words (not code) exactly what you hope to achieve in the piece of code that is not working (this is often a healthy trick when something doesn't work - by articulating the problem you can often recognize if you've overlooked something obvious or better in the design).