Recent Topics

1 Sep 11, 2005 19:25    

Hey guys- Im doing a little work for a guy who uses b2evo, and this is my first foray into it.
Ive run into a lot of problems while trying to query databases with b2evo, so am asking yall for help.
What I need is this:
for the Category side-bar list, Each category must be displayed (as a link to that cat) with three blurbs from the most recent posts underneath each category.
I suppose if nobody can answer that, maybe someone could just explain the proper method of querying the database?
Ive tried $db->query( "select blablabla" ); to no real success... Any input?

Thanks!

2 Sep 11, 2005 21:52

Hey all-
Got around it by using a dirty, nasty hack.
(created a seperate mysql session and just used that one to grab what I needed)

I would still, however, like to know the _proper_ way to query through b2evo...

3 Sep 11, 2005 22:18

If you can search all files in a folder try searching for "$DB->query". That'll show you quite a few different ways to pull database content. As a general rule it'll go something like this:

	$sql = "UPDATE $tablewhatever SET Field = '$variable' WHERE OtherField = '$somethingelse'";
	$DB->query( $sql );


I always get tripped up trying to figure out exactly which type of query I need to make in order to do whatever it is I'm doing. Not the $sql part - the $DB->query" part. There's a bunch of different ways to do that part, and it always messes with me.

As to the initial question, it's kinda tough. At least, nothing pops to mind as "oh this is how". The thing you want to do is basically for each category identified after showing it linked with the quantity in parentheses go get the first three posts and pull a snippet from them. Maybe looking at the category-specific URL will help you understand how it gets those posts (thus enabling duplication for the first 3), then getting a snippet isn't so hard.
http://doc.b2evolution.net/0.9.0/evocore/Item.html#methodcontent tells me you can try to manipulate IT to snag only a few words. $cut is the number of words, and $format would need to be 'xml' in order to actually use $cut. I was working on a skin that used that gimmick but deleted it for some stupid reason.

By the way http://doc.b2evolution.net/0.9.0/elementindex_evocore.html is a resource you might find very handy. Generally 2 clicks and you get all the goodies about params you can feed any function. Item::content is a wierd one because it is listed twice after clicking on the letter c.

4 Sep 12, 2005 01:11

To handle the category thing I wanted to do, I changed _main.php to include my own _categories.php file (called it _newCategories.php), I just did it w/ basic php in there, grabbed category name/ids, grabbed articles linked to those ids (order by newest, limit 0,3) and spit it out in an unordered list. The effect is quite pleasing, actually :)

Thanks for the help on the $db->query stuff... I messed around with a lot of the different commands b2evo gives ya, but gave up. For now, I have written my own db_connect() that makes a new connection and kills it once its done so as not to interfere with the rest of b2evo.


Form is loading...