Plugin: bbMenu 0.1 beta
-
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:
-
Well the switch gives this error:
Parse error: parse error, unexpected $ in /xxx/bbpress/my-plugins/bbmenu.php(123) : eval()’d code on line 1
Isn’t there a simpler way? Like always underline Forum unless $rw == get_bb_location()
So if current isn’t present in the li list, uinderline Forums. If this is possible, it would solve all problems
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.
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 == 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…
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).
I FINALLY fixed it!! YESSSSSSSSSSSSS
What did I do? Well simply replace bb_get_location output with: front-page.
It even doesn’t chance the page id
Perhaps it’s a “dirty” fix, but it works:
function get_bb_menu() {
global $bbdb;
$pemal = get_bb_location();
$pemal = str_replace('topic-page', 'front-page', $pemal);
$pemal = str_replace('profile-page', 'front-page', $pemal);
-normal code goes here-
Going to do some more testing and then it’s ready for release!
ps ow and ear1grey, thx for your help and patience
Cool! So now the CSS fix?
class class class
I get this error when I activate this plugin and go to the Menu management page on my backend:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/…./public_html/forums/my-plugins/bbmenu.php on line 88
Where did you install it? Did you install more plugins? Which version of bbPress are you running? Is the bb_menu table created? Did you refresh the page and still get the error? What MySQL/ php version do you use?
I need more info
i was only able to fix the error by adding an @ sign before the myql_fetch_array functions, but that just outputted a blank page.
I’m running .73.
bb_menu table is created, but cannot browse the structure since it has no entries.
I did refresh several times and had the same error.
Running php version 4.4.4
MySQL version 4.1.21
Hmm it should have entries, something went wrong there.
If you can, delete the bb_menu table.
Then in phpMyAdmin:
CREATE TABLE
bb_menu(
set
varchar(50) NOT NULL default '',
item
varchar(50) NOT NULL default '',
page
varchar(50) NOT NULL default '',
location
varchar(50) NOT NULL default '',
order
int(9) NOT NULL default '0',
PRIMARY KEY (set
,
item)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
If your current bb_menu already has these values, you wont have to recreate it. But better save then sorry…
Now fill the table:
INSERT INTO
bb_menuVALUES ('active', 'Forums', 'index.php', 'front-page', 0)
INSERT INTO bb_menu
VALUES ('active', 'Search', 'search.php', 'search-page', 1)
INSERT INTO bb_menu
VALUES ('available', 'Statistics', 'statistics.php', 'stats-page', 0)
Now refresh the admin page. This should fix it. Not sure if I gave the right syntaces to use in phpMyAdmin, but you get the idea
ps. If you didn’t use the bb_ prefix, you should change this…
ps2. And leave out the @
ps3. This is the beta so it has some errors that are fixed in the final release (after bbPress 0.8 is out)
I couldn’t create the table using the code you posted, it throwed a MySQL error in phpMyAdmin.
So I used the plugin to create the table, but had the same problem where it was empty.
I tried running hte second SQL query on the table, but got the following error:
#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘INSERT INTO bb_menu VALUES (‘active’, ‘Search’, ‘search.php’, ‘search-page’, 1)
‘ at line 2
Ok, I am at work now, so when I get home (tonight) I will cook up some correct SQL code for you. The problem is that the table isn’t filled so thats why it said: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource because the table is empty.
The thing that borthers me is why it doesn’t fill the table when it is created :S (any1 has any ideas about this?)
So your original error is easily fixed, but you will have to wait till I get home.
Greetz
alright good times Null (y)
Null, did you make any progress on this lately?
The code I gave you works fine here.
Well since it does create the bb_menu table I suggest you fill it manually with phpma.
Use these lines:
INSERT INTO bb_menu VALUES (‘active’, ‘Forums’, ‘index.php’, ‘front-page’, 0)
INSERT INTO bb_menu VALUES (‘active’, ‘Search’, ‘search.php’, ‘search-page’, 1)
INSERT INTO bb_menu VALUES (‘available’, ‘Statistics’, ‘statistics.php’, ‘stats-page’, 0)
But NOT all at once. Do them 1 by 1 so like:
INSERT INTO bb_menu VALUES (‘active’, ‘Forums’, ‘index.php’, ‘front-page’, 0)
presss Go
Then enter line 2 etc etc
I am in the final stage of releasing this for 0.8, but I still don’t know why your table isn’t filled like it should…
thanks null, i’ll wait until the next release.
Null, I couldn’t get this to work. I experienced the same issues as suleiman. I looked at your SQL, and found some errors involving your column names: you’re using mySQL keywords as column names, like “set”.
I tried
CREATE TABLE bb_menu(
sett varchar( 50 ) NOT NULL default ”,
item varchar( 50 ) NOT NULL default ”,
page varchar( 50 ) NOT NULL default ”,
location varchar( 50 ) NOT NULL default ”,
orderr int( 9 ) NOT NULL default ‘0’,
PRIMARY KEY ( sett, item )
but still got an error:
MySQL said: Documentation
#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 7
Notice I changed “set” to “sett” and “order” to “orderr”. I think you’re on the right track tho. Let me know if I can help further. I’ll check this thread periodically because I’d like to see this plugin work.
Hi,
Plz go to this thread and keep an eye on this one since the beta is closed:
https://bbpress.org/forums/topic/743?replies=11
Thx
- You must be logged in to reply to this topic.