Recent Topics

1 Aug 30, 2006 01:36    

I've had b2evo up and running for about six months but never turned on the previous/next links. When I do, I find previous/next goes through the articles in all the blogs, not just the one blog they are reading. This is confusing for newbee users.

I'm reorganizing the website which will have the following blogs: Home, Around Town Business Services, Calendar, Community Concerns, and Newsmaster (Home, Business Services, and Calendar are all one page, the rest are multiple pages). When you go to single page mode in, say, Community Concerns, and go to previous/next links it goes to the previous/next in time order across ALL the blogs, not just the one you've gone to single page mode from (to view/post comments or read more).

I had a look at the source for previous/next links and while I'm not fully up to speed on MySQL, I can see it just looks for the previous/next article without limiting it to a particular blog. (I notice I can set it to go to the previous/next in the same category, but the blogs I want users to be able to cycle through have multiplace categories.)

To make sure I understood what was happening, I posted two articles in the Around Town blog and one in a Test blog that have times like this:

8/27/06 5:15:54pm Around Town blog
8/27/06 5:15:45pm Test blog
8/27/06 5:15:28pm Around Town blog

When I use previous/next in Around Town, it includes the one from Test. This is confusing to newbee users of the website who don't even know how to use their browser's Back Button. So I've got the various blogs at the top of the page and want them to be able to go through a particular blog in single page mode as can be done with TypePad and MovableType (which I have on a different website).

I'm hoping it's possible to rewrite the previous/next link functions so they will stay within a single blog.

Any ideas?

2 Aug 30, 2006 01:47

Is your Around Town blog #1? Blog #1 is an aggregator blog, so it contains all posts from all blogs. Therefore what you're seeing is normal for blog #1. I just checked my 1.8.1 installation and on a blog other than #1 I could not duplicate your problem.

3 Aug 30, 2006 02:31

Thanks for the quick reply. Here's the details:

There are a total of 19 blogs right now. Current operational setup has #3 as default and #5, 6, 7, 8, 9, 10, 11, 12, 13 as additional. None of them have "Display public blog list" or "Include in public blog list" set. Instead there is an HTML home page www.congress-arizona.com which references these blogs.

Under the yet-to-be-completed new setup #14 will is default, #16, 17, and 18 (no #15) are additional and all have "Display public blog list" and "Include in public blog list" set. In addition there's a #19 which has the 8/27/06 5:15:45pm posting.

If you go to www.congress-arizona.com/b2evolution/index.php?blog=14, you will see the Home page. click on "AT" (for Around Town) and you will see the top two postings are

"Title #3" 8/27/06 5:15:54pm
"Title #2" 8/27/06 5:15:28pm

Click on the "Read More" for "Title #3" and you will see my debugging statments on the left sidebar indicating that the Previous Post is "Title #2.5". When you click to read it, you get the title and "Sorry, there is no post to display..." because it is looking for p=169 in blog #18 (AT) but the posting with that Id is in blog #19.

Looking at the code for previous_post you can see this:

$string = '<a href="'.url_add_param( get_bloginfo('blogurl'), 'p='.$p_id.'&amp;more=1&amp;c=1').'">'.$previous;

If you look at the source for the page, you can see that the blogurl is for #18 (the blog in which you clicked "Read More"), not #19 (where the "Title #2.5" is located).

4 Aug 30, 2006 02:51

Because I've recently fixed something in those functions I confirm that they do not stay in the same blog.
You can let them use the same main cat though (there's a param), but that is not really what you seem to want.

5 Aug 30, 2006 03:38

Not sure what the "main cat" is and where the param might be. Please advise.

What I want is to have people read an article in a particular blog and click through to single page mode (either to Read More, or to leave/Read a comment) and then be able to move to previous/next articles within the same blog.

Actually, the complaint from my users is they had no way to return to the main or home blog which I've remedied by having links to all the blogs at the top of the page (by setting "Display public blog list" or "Include in public blog list"). Then they wanted to return to the same article in the same blog in which clicked through to single page mode. As far as I know this isn't possible for either b2evo, TypePad, or MovableType. But at least they could continue reading articles in single page mode within a blog.

7 Aug 30, 2006 20:25

If I understand you, the workaround would be to assign different main categories to each blog with other categories as needed. Then when you call
next/previous post you could specify that they need to be in the same (main) category.

While this may work (haven't tried it yet), it doesn't address the problem that the next/previous functions pull up ID's which may or may not be in the same blog, and then use get_bloginfo('blogurl') to get the number of the current blog and use it generate the URL which can result in an error.

As I said in my original post, I'm not fully up to speed on MySQL so I haven't been able to figure out how b2evo is able to list just the articles in a single blog whereas the next/previous functions only pull information from $tableposts. For some reason I don't understand next/previous use a different method which can be in error.

Can you shed any light on this?

8 Aug 30, 2006 21:57

Maybe that would get improved in b2evo 2.0 and it should be possible to hack it already now in there.

Might be a good chance to digg into b2evo/PHP/MySQL.. ;)

9 Aug 31, 2006 03:56

I would think it would be possible to hack it to do what I want. Not sure what you mean by 'b2evo/PHP/MySQL' is that in my installation?

Would you know any general overview of how the MySQL data base is set up? I understand the code in next/previous functions and have dumped my whole data base and looked through it but don't see how how the articles are assigned to particular blogs. Maybe each blog's articles are in a separate column? Only making a wild guess ....

10 Aug 31, 2006 08:38

I think I can get this one right. Posts are assigned to categories and categories are assigned to blogs, so when someone visits a blog they're really visiting all the categories (and sub-categories) in that blog. This is why limiting to a specific category will limit to a specific blog.

There is somewhere a graphical representation of the database. Really cool, but I can't find the link to it right now. If someone shares it you'll be way up on figuring out how the database ties itself together. That won't help explain why this does this and that does that, but hey at least it's a cool image ;)

12 Sep 01, 2006 19:27

The problem also exists when you're using stub files.

I have blog #6 and blog #5. Blog #6 is called through the stub file v1.0.php and blog #5 is called through index.php (it's the default). The previous_post(), next_post() don't realize they are calling a post in different post, and then you get an error message.

This behavior can be seen here: http://liberal-venezolano.net/blog/v1.0.php/2005/01/05/mercado_libre_salvese_qpueda

"Post anterior" is "previous post" and is in the same blog #6 (v1.0.php), but the next post ("Post siguiente") is in the default blog (blog #5), therefore it should be called through index.php and not through v1.0.php. It happens the same if you're in blog #5 and next/previous post is in blog #6.

13 Sep 01, 2006 21:10

I think, but I have a problem. What I did is modify the following in ./inc/MODEL/items/_item.funcs.php, in function previous_post(), line 262 add:

 $current_blog = $postdata['Blog'] ; 

The modify the SQL (line 280) like this:

$sql = "SELECT post_ID, post_title
                                                                     FROM T_posts
                                                                     INNER JOIN T_categories ON post_main_cat_ID = cat_ID
                                                                     WHERE cat_blog_ID = " . $current_blog ." AND post_datestart < '$current_post_date'
                                                                                        $sqlcat
                                                                                        $sql_exclude_cats
                  AND ".statuses_where_clause()."
                                                                              ORDER BY post_datestart DESC
                                                                              LIMIT $limitprev, 1";

What I was supposedly doing is asking for posts which are in the same blog as the current post. Except that I get and error because $current_blog, i.e. $postdata['Blog'] is empty for some reason I don't know at the moment.

When I try a similar SQL directly in the MySQL prompt I get the desired result:

SELECT post_ID, post_datestart, cat_blog_ID FROM evo_posts INNER JOIN evo_categories ON post_main_cat_ID = cat_ID WHERE post_datestart > '2004-07-22 17:59:06' AND cat_blog_ID = 6 ORDER BY post_datestart ASC LIMIT 20 ;
+---------+------------------------------------------+-------+
| post_ID | | post_datestart | cat_blog_ID |
+---------+------------------------------------------+-------+
| 124 | | 2004-07-27 19:23:55 | 6 |
| 125 | | 2004-07-30 19:34:00 | 6 |
| 134 | | 2004-08-13 17:04:01 | 6 |
| 135 | | 2004-08-25 17:09:40 | 6 |
| 136 | | 2004-09-03 17:11:02 | 6 |
| 140 | | 2004-09-10 18:55:34 | 6 |
| 141 | | 2004-09-16 18:56:48 | 6 |
| 142 | | 2004-09-28 18:58:26 | 6 |
| 380 | | 2004-10-08 11:24:20 | 6 |
| 170 | | 2004-10-19 00:22:00 | 6 |
| 188 | | 2004-11-22 17:59:06 | 6 |
| 198 | | 2005-01-05 04:36:58 | 6 |
+---------+---------------------------------------+------+
12 rows in set (0.01 sec)

The question is: is this pointing in the right direction? Why is $postdata['Blog'] empty there?

14 Sep 01, 2006 22:58

previous/next links go through all blogs

I've had b2evo up and running for about six months but never turned on the previous/next links. When I do, I find previous/next goes through the articles in all the blogs, not just the one blog they are reading. This is confusing for newbee users.

I'm reorganizing the website which will have the following blogs: Home, Around Town Business Services, Calendar, Community Concerns, and Newsmaster (Home, Business Services, and Calendar are all one page, the rest are multiple pages). When you go to single page mode in, say, Community Concerns, and go to previous/next links it goes to the previous/next in time order across ALL the blogs, not just the one you've gone to single page mode from (to view/post comments or read more).

I had a look at the source for previous/next links and while I'm not fully up to speed on MySQL, I can see it just looks for the previous/next article without limiting it to a particular blog. (I notice I can set it to go to the previous/next in the same category, but the blogs I want users to be able to cycle through have multiplace categories.)

To make sure I understood what was happening, I posted two articles in the Around Town blog and one in a Test blog that have times like this:

8/27/06 5:15:54pm Around Town blog
8/27/06 5:15:45pm Test blog
8/27/06 5:15:28pm Around Town blog

When I use previous/next in Around Town, it includes the one from Test. This is confusing to newbee users of the website who don't even know how to use their browser's Back Button. So I've got the various blogs at the top of the page and want them to be able to go through a particular blog in single page mode as can be done with TypePad and MovableType (which I have on a different website).

I'm hoping it's possible to rewrite the previous/next link functions so they will stay within a single blog.

----------

Thanks for the quick reply. Here's the details:

There are a total of 19 blogs right now. Current operational setup has #3 as default and #5, 6, 7, 8, 9, 10, 11, 12, 13 as additional. None of them have "Display public blog list" or "Include in public blog list" set. Instead there is an HTML home page www.congress-arizona.com which references these blogs.

Under the yet-to-be-completed new setup #14 will is default, #16, 17, and 18 (no #15) are additional and all have "Display public blog list" and "Include in public blog list" set. In addition there's a #19 which has the 8/27/06 5:15:45pm posting.

If you go to www.congress-arizona.com/b2evolution/index.php?blog=14, you will see the Home page. click on "AT" (for Around Town) and you will see the top two postings are

"Title #3" 8/27/06 5:15:54pm
"Title #2" 8/27/06 5:15:28pm

Click on the "Read More" for "Title #3" and you will see my debugging statments on the left sidebar indicating that the Previous Post is "Title #2.5". When you click to read it, you get the title and "Sorry, there is no post to display..." because it is looking for p=169 in blog #18 (AT) but the posting with that Id is in blog #19.

Looking at the code for previous_post you can see this:

$string = '<a href="'.url_add_param( get_bloginfo('blogurl'), 'p='.$p_id.'&amp;more=1&amp;c=1').'">'.$previous;

If you look at the source for the page, you can see that the blogurl is for #18 (the blog in which you clicked "Read More"), not #19 (where the "Title #2.5" is located).

----------

Not sure what the "main cat" is and where the param might be. Please advise.

What I want is to have people read an article in a particular blog and click through to single page mode (either to Read More, or to leave/Read a comment) and then be able to move to previous/next articles within the same blog.

Actually, the complaint from my users is they had no way to return to the main or home blog which I've remedied by having links to all the blogs at the top of the page (by setting "Display public blog list" or "Include in public blog list"). Then they wanted to return to the same article in the same blog in which clicked through to single page mode. As far as I know this isn't possible for either b2evo, TypePad, or MovableType. But at least they could continue reading articles in single page mode within a blog.

----------
If I understand you, the workaround would be to assign different main categories to each blog with other categories as needed. Then when you call
next/previous post you could specify that they need to be in the same (main) category.

While this may work (haven't tried it yet), it doesn't address the problem that the next/previous functions pull up ID's which may or may not be in the same blog, and then use get_bloginfo('blogurl') to get the number of the current blog and use it generate the URL which can result in an error.

As I said in my original post, I'm not fully up to speed on MySQL so I haven't been able to figure out how b2evo is able to list just the articles in a single blog whereas the next/previous functions only pull information from $tableposts. For some reason I don't understand next/previous use a different method which can be in error.

Can you shed any light on this?

----------

Makes sense the posts are assigned to categories and categories are assigned to blogs and thus a blog is a collection of all the posts in the assigned catgories. Thus there must be something in the database that tells which categories are assigned to which blogs and categories must have unique identifiers so they can have the same name in different blogs.

Instead of looking for how this is done in the database, I poked around until I found how the list of categories is generated for the sidebar in
cat_list_before_each() in _categories.php.

Next, I played around with the call to mySQL in previous/next posts and changed them so when in_same_cat == 'yes' it would make the call with

$sqlcat = " AND ( post_category=51 OR post_category=52 )"

(51 and 52 are the numbers of the two categories in the blog I'm using to test things out: later they will be any categories).

So far so good: when somebody goes to Single Page Mode, the previous/next functions worked so only the posts in the blog were referenced whether they had a category of 51 or 52 and posts outside of the blog were not included.

Next was to pass the current categories to the previous/next functions and I accomplished this by adding a line to cat_list_before_each() to push the category numbers into a global array accessable by the functions. The mickey mouse part was that cat_list_before_each() had to run BEFORE the sidebar was sent: I did this by letting it run inside an ob_start() which captured the output and sent it to the display in the appropriate place.

Only one more thing to finish up: As it is right now, when a user selects only certain categories to be displayed the categories are included in the command line to index.php and show up in the $catsel array. But when the users switches to Single Page Mode, the categories are NOT included in the command line and thus when they use previous/next they get entires from the whole blog, not just from the selected categories. I'll add those categories to the command line when a user goes to Single Page Mode.

There's probably a more elegant way to get the results I have in mind but it looks like it's going to work.

15 Sep 02, 2006 01:45

Austriaco, I think you're on the right track. Actually it's "just" a bug in 1.8 that "Blog" is not set for the $postdata global.

To fix it, add in blogs/inc/MODEL/items/_itemlist.class.php around line 780 this line:

         'Blog'       => $this->last_Item->blog_ID,


(in Itemlist::get_postdata()).

I'll attach the patch to make this work in 1.8.x and commit it, so it hopefully makes it into the 1.8.2 release.

16 Sep 03, 2006 06:30

Retrofitting B2evolution previous/next functions
------------------------------------------------
The users of my website, www.congress-arizona.com, are not up to speed, to the point where they don't know how to use their browser's Back Button and get stuck when there is no explicit link on the page. My first step was to use b2evo's Blog List so they could at least jump to the top of the current or other blog.

In addition I decided to add the previous/next functions so once users went to Single Page Mode so they could navigate blogs without having to leave Single Page Mode and return to the top of the blog. But, I found some problems:

1) The previous/next functions didn't just cycle through postings in the current blog, but included postings for other blogs as well. Checking the code I found this was because they simply called upon MySQL for the previous/next posting according to time, and didn't try and stay with only the postings for the current blog.

2) Once I had changed things so the functions stayed with only the postings for the current blog, I found that when the posting had been selected according to one or more categories, once the user had gone to Single Page Mode the previous/next functions just cycled through all of the postings, not just the ones that had been selected by category(s).

3) After I had changed things so functions would stayed with only the postings that had been selected, I had to decide whether the permalink in Single Page Mode should return to the posting with the same category(s) selected, or not. I decided that it should not: I let permalinks return to the same posting in Single Page Mode with the full set of categories selected. This way I didn't have to think about what to do if the categories had changed from the time the permalink was made and the user used it. In addition, if users had bookmarked a particular posting in a category selected group, I removed categories which were no longer assigned to the blog,

What started out with what I thought would be a relatively simple fix got to be complicated (as usual). Below are summaries of changes to the various files that accomplish the above. If you'd like to see the files, I'd be glad to send them to you.

Dave McLane, davemclane@congress-arizona.com.

Change _main.php
----------------
1) Insert new code such that if $catsel is set, it's copied to $congress_catsel, otherwise generate $congress_catsel by calling _categories.php inside an ob_start.

2) Change the way _categories.php is called in the Sidebar so it uses the saved ob buffer from 1) above.

3) Change the way the two sets of previous/next functions are called so they use the _HACK version with _in_same_code = 'yes'.

Note: I suppose I could have split _categories.php into two parts with the first producing an array of categories (horribly complex code) and the second displaying those categories in the Sidebar. But the ob_start method was much easier and I needed to this done ASAP.

Change _categories.php
----------------------
1) Add a line to cat_list_before_each() to push $cat_ID onto $congress_catsel.

Change _functions_bposts.php
----------------------------
1) Make new previous_post_HACK and next_post_HACK so they use $congress_catsel so $sqlcat will select only the categories in $congress_catsel.

Change _class_item_php
----------------------
1) Change feedback_link() so it adds either $catsel or $congress_catsel parameters to the comments link: if $catsel is empty, use $congress_catsel.

2) Change content() so it adds $catsel parameters to the Read More link.

Change _blog_main.php
---------------------
Add a debugging line to check when catsel parameters are received.

17 Jan 07, 2007 13:41

blueyed wrote:

To fix it, add in blogs/inc/MODEL/items/_itemlist.class.php around line 780 this line:

         'Blog'       => $this->last_Item->blog_ID,


(in Itemlist::get_postdata()).

After two late nights of scratching my head, I'm thrilled to finally find the answer! Thank you!


Form is loading...