Recent Topics

linkblog order is strange

Started by on Jun 15, 2004 – Contents updated: Jun 15, 2004

Jun 15, 2004 23:54    

(i'm using 9.0.8 now, upgraded from 9.0.5, no change... it must be my db)

this is the strangest thing, when i post a new linkblog entry it sticks it in the middle of the linkblog list when viewed through any skin. actually it sticks them in at, (seems) at random. but it doesn't change the order on a refresh.

i tried setting it to ASC and DES, doesn't fix it. but in the backoffice it displays them in the correct order, DES or ASC respectivly.

any ideas?

Jun 16, 2004 06:35

Im pretty sure it does it alphabetically

Jun 16, 2004 08:12

can i get it to display by order of time of post?

Jun 16, 2004 21:41

Well, the links inside the categories os likroll get alphabeticaly listes..

But the categories are listed in the order of creation..(is this a bug ?)

[]?s
- Walter

Jun 17, 2004 05:12

i should prolly just use "multiblogs.php" and incorporate that idea into my skin.

thanx for everything guys

Jun 27, 2004 18:51

Is there any update on being able to display the linkblog by category title, rather than category Id?

Jul 29, 2004 14:03

Is it possible to re-order the linkblog by date instead of alphabetically?

How can I make that happen?

Thanks--
Molly

Aug 06, 2004 20:44

I'm interested in listing the linkblog categories alphabetically as well. Has anyone come up with a solution that works? Any ideas? I'm not really sure where to start.

Aug 08, 2004 01:07

The only idea I've had so far is to play around with the sort function. And I'm getting nowhere.

Aug 09, 2004 07:39

Ok, here's what has to be done, and why this is tricky.

Might wanna open up blogs/skins/_linkblog.php to follow along.

We open up the linkblog like this on line 46:

Code

$LinkblogList = & new ItemList( $linkblog, array(), '', '', '', $linkblog_cat, $linkblog_catsel, '', 'ASC', 'category title', '', '', '', '', '', '', '', '', $linkblog_limit, 'posts', $timestamp_min, $timestamp_max );
Here's that line explained:

$LinkblogList = & new ItemList(
$linkblog, // the ID of the blog that we want, set earlier in the file
array(), // the post statuses to grab. array() is the default.
'', // specific post number to display - none selected
'', // YYYYMMDD to display - none selected
'', // week number to display - none selected
$linkblog_cat, // list of cats to display - recursive
$linkblog_catsel, // array of cats to display - non-recursive
'', //list of authors to restrict to
'ASC', // ASCending or DESCending
'category title', // fields to sort by, in the order to use them
// some other stuff:
'', '', '', '', '', '', '', '', $linkblog_limit, 'posts', $timestamp_min, $timestamp_max );

Then, it creates a SQL command kinda like this:

SELECT DISTINCT ID, post_author, post_issue_date, post_mod_date,
post_status, post_locale, post_content, post_title,
post_urltitle, post_url, post_category,
post_autobr, post_flags, post_wordcount, post_comments,
post_renderers, post_karma
WHERE blog_id = $linkblog
ORDER BY post_category, post_title

Note that it adds post_ to the strings that are passed in.

Here's how you could do it, but it's a big ugly core-file-modifying hack. A more elegant solution would be preferrable.

0. Back up b2evocore/_class_itemlist.php, and the _linkblog.php and _blogroll.php files that you modify. This is never a bad idea.
1. Open up b2evocore/_class_itemlist.php
2. Around line 355, find this bit:

Code

else
    {
      $orderby_array = explode(' ',$orderby);
      $orderby = $orderby_array[0]. ' '. $order;
      if (count($orderby_array)>1)
      {
        for($i = 1; $i < (count($orderby_array)); $i++)
        {
          $orderby .= ', post_' . $orderby_array[$i]. ' '. $order;
        }
      }
    }
Change it to this:

Code

else
    {
      $add_postpref = ( strpos($orderby, '.') === false );
      $orderby_array = explode(' ',$orderby);
      $orderby = $orderby_array[0]. ' '. $order;
      if (count($orderby_array)>1)
      {
        for($i = 1; $i < (count($orderby_array)); $i++)
        {
          $orderby .= ', ' . ($add_postpref ? 'post_' : '') . $orderby_array[$i]. ' '. $order;
        }
      }
    }
Note the added line ($add_postpref) and the change to the "$orderby .= ..." line.

3. Around line 496 (it WAS 495, but we added a line in step 2), find this bit:

Code

$this->request .= $where. " ORDER BY post_$orderby $limits";
Replace it with this:

Code

$this->request .= $where. " ORDER BY " . ($add_postpref ? 'post_' : '') . "$orderby $limits";

4. Save and close _class_itemlist.php
5. Open up skins/_linkblog.php, or skins/skin_name/_linkblog.php, or skins/_blogroll.php or skins/skin_name/_blogroll.php
6. Find this line:

Code

$LinkblogList = & new ItemList( $linkblog, array(), '', '', '', $linkblog_cat, $linkblog_catsel, '', 'ASC', 'category title', '', '', '', '', '', '', '', '', $linkblog_limit, 'posts', $timestamp_min, $timestamp_max );
Replace it with this:

Code

$LinkblogList = & new ItemList( $linkblog, array(), '', '', '', $linkblog_cat, $linkblog_catsel, '', 'ASC', $tablecategories.'.cat_name post_title', '', '', '', '', '', '', '', '', $linkblog_limit, 'posts', $timestamp_min, $timestamp_max );

I found that this can produce odd results if your linkblog posts are in multiple categories. I recommend saving the affected post in just a single category if that happens - this hack is ugly enough as it is.

[url=http://b2evolution.net/dev/todo/2004/08/09/category_order_in_linkblog]I've added this issue to the ToDo list.[/url]

Aug 09, 2004 16:30

8|

Thank you for the thorough explination along with the modified code Isaac. I'd only been plaing with the bit you mentioned from /skins/_linkblog.php so far. It's too bad this sort of thing requires core file hacking. One of the things I like so much about b2evo is that the skins and core files are so well seperated.

I'm willing to give this a try. Thank you very much for posting.

Aug 09, 2004 16:36

I was thinking about it..

Could be a useful feature to b2evo has a way to identid the linkblog blogs and doesn?t allow more than a category by post..

[]?s
- Walter

Feb 02, 2005 12:59

I like the linkblog feature, but I really don't see the use if it's in alphabetical order only. How will people know when there's a new story?

Anyway I tried the core hack that was listed but it just game me an error and the site wouldn't load. I don't see this change listed any more on the To Do list either. What gives?

Is this feature going to be fixed in the future?

Feb 02, 2005 14:32

Generally speaking a linkblog isn't really a place for story telling. You of course can have content with your linkblog posts, but it'll show up in the sidebar, which can make for a very long sidebar over time. Anyway to answer your question: cross-post in your blog-blog and linkblog.

Feb 02, 2005 15:31

I guess the thing I'd like to see is a sidebar that lists the 4 or 5 most recent posts from another blog, such as the linkblog. I guess this could be done using RSS or something else, but the linkblog sidebar code is already there and just needs some kind of tweek to get it to do this.

Feb 16, 2005 01:19

mollyc wrote:

Is it possible to re-order the linkblog by date instead of alphabetically?

How can I make that happen?

Thanks--
Molly

yeah...

Feb 16, 2005 01:32

Err... wtf? Thats giving me a huge error...

MySQL error!

Unknown column 'issue_date' in 'order clause'(Errno=1054)

Your query:
SELECT DISTINCT ID, post_author, post_issue_date, post_mod_date, post_status, post_locale, post_content, post_title, post_urltitle, post_url, post_category, post_autobr, post_flags, post_wordcount, post_comments, post_renderers, post_karma FROM (evo_posts INNER JOIN evo_postcats ON ID = postcat_post_ID) INNER JOIN evo_categories ON postcat_cat_ID = cat_ID WHERE cat_blog_ID = 2 AND ( ( post_status = 'private' AND post_author = 1 ) OR post_status IN ('published','protected') ) AND post_issue_date <= '2005-02-15 18:31:20' ORDER BY issue_date DESC LIMIT 20

Feb 16, 2005 02:10

Look at the error.

unknown column 'issue_date'...

There is no such column, so it won't work. The very last bit of the error message tells you it is trying to ORDER BY this non-existant column.

...ORDER BY issue_date DESC...

Now look at your hack and change issue_date to post_issue_date.

Feb 16, 2005 02:12

I dont see where that code is though...

Feb 16, 2005 02:20

K, well. I dont get any errors, but I don't get any results either. This hack doesnt work, I guess...

Mar 09, 2005 11:43

I have to agree: it's a major nuisance that the linkblog can simply be switched between date-order and alphabetical-order. How difficult would it be to change this for the next update?

Jan 27, 2006 04:54

$LinkblogList = & new ItemList(
$linkblog, // the ID of the blog that we want, set earlier in the file
array(), // the post statuses to grab. array() is the default.
'', // specific post number to display - none selected
'', // YYYYMMDD to display - none selected
'', // week number to display - none selected
$linkblog_cat, // list of cats to display - recursive
$linkblog_catsel, // array of cats to display - non-recursive
'', //list of authors to restrict to
'ASC', // ASCending or DESCending
'category title', // fields to sort by, in the order to use them
// some other stuff:
'', '', '', '', '', '', '', '', $linkblog_limit, 'posts', $timestamp_min, $timestamp_max );

What are other choices for "Sorting By"

Can i do "Post Date", or "Post Name", etc?

Mar 27, 2006 21:08

I couldn't figure out the post_issue_date problem either, but I know about ZERO with regard to MySQL.

My solution was simply to change ASC to DSC (thanks for showing that I could do that isaac in your SQL query explanation). This works as I title my Linkblog posts with a date - "Week ending 2006:04.01"

My new problem is that I can't seem to figure out how to eliminate the space after the post title. I don't see any br codes in there in the linkblog.php (the main one) ... Any idea how to do this? (www.autodogmatic.com)

Neal

Mar 30, 2006 19:46

Okay, another weird thing: the spacing between the first heading (it's bolded) and the first list is greater than the second heading and the second list. There's no break tags or hard returns to warrant this space. Anybody got any ideas? This seems like a firefox issue as in IE it's fine.

[url=www.autodogmatic.com]autoDogmatic[/url]


Form is loading...

Social CMS software – This forum is powered by b2evolution CMS, a complete engine for your website.