Recent Topics

1 Oct 29, 2007 07:20    

My b2evolution Version: 1.10.x

I have recently installed B2evo 2.0.2 and, while tinkering around, I've noticed: why do category URLs actually have to be unique?

I mean... I have several blogs that share simmilar category names, while being served from different blog stubs. I would expect to see something like:

http://example.com/blogA/funny/
http://example.com/blogB/funny/

Meanwhile, it turns out I can't have "funny" as a category URL, because B2evo complains about:
"This URL name is already in use by another category. Please choose another name."

Sure, it's used by another category... [u]in a different blog[/u], with a different stub and naming convention.

Does anybody know of a way around this issue?

2 Oct 29, 2007 13:19

Hi jarfil,

In your reasoning you forget that it is possible to crosspost in different categories. So funny can becaome a category of both blog A and blog B even if it is originally a category of blog B. Therefore category names *must* be unique.

This behaviour may be both a limitiation but also a solution to your problem.

Good luck

3 Oct 29, 2007 15:26

Right, I don't use crossposting between blogs. Unfortunately, this wouldn't work for me, as having duplicate content on several URLs doesn't appeal to me.

So, as far as I see, there would be two main scenarios related to category URL names:

Case 1

  • No crossposting between blogs

  • Category URL names need only to be unique [u]inside each blog[/u]

  • [/list:u] Case 2
    • Cross-posting between blogs enabled

    • Category URL names must be unique [u]globally[/u] OR they must be [u]redefinable[/u] for each blog.

    • [/list:u] There could also be a mixed case 1+2 where, on a single system, some blogs would crosspost between themselves and some would not. So... actually having category URL names redefinable on a per-blog basis, with some mechanism to solve duplicates, should do it.

4 Oct 29, 2007 15:54

Funny thing, I started hacking around, and seems like I've found a way that works for me... and yet retaining part of the prior behaviour. It shouldn't be difficult to extend this in order to allow for different Category URL naming scenarios.

In order to DISABLE multiple blog crossposting category URL name auto-detection:

ALTER TABLE `evo_categories` DROP INDEX `cat_urlname` 


conf/_admin.php

$allow_cross_posting = 1;


inc/chapters/model/_chapter.class.php


      /*
        if( Chapter::urlname_exists( $this->urlname, $this->ID ) )
        { // urlname is already in use
          param_error( 'cat_urlname', T_('This URL name is already in use by another category. Please choose another name.') );
        }
        */


inc/_blog_main.inc.php


          /**
           * @var Chapter
           */
          $Chapter = & $ChapterCache->get_by_urlname( $last_part, false, $blog->ID );
          if( empty( $Chapter ) && ( $Blog->ID !== null ) && ( $allow_cross_posting > 2 ) )
          { // We could not match a chapter in the current blog...
            // We are going to check for crossposted categories.
            $ChapterCache->clear();
            $Chapter = & $ChapterCache->get_by_urlname( $last_part, false );
          }


inc/chapters/model/_chaptercache.class.php


  function & get_by_urlname( $req_urlname, $halt_on_error = true, $blog_ID = null )
  {
    global $DB, $Debuglog;

    if( !isset( $this->urlname_index[$req_urlname] ) )
    { // not yet in cache:
      // Load just the requested object:
      $Debuglog->add( "Loading <strong>$this->objtype($req_urlname)</strong> into cache" );
      $sql = "SELECT *
                FROM $this->dbtablename
               WHERE cat_urlname = ".$DB->quote($req_urlname);
      if ( $blog_ID !== null )
      {
        $sql .= " AND cat_blog_id = $blog_ID";
      }

5 Jan 02, 2008 02:05

Does it work?
I have the same problem, so I would like to know what the developers think about this patch? Is it safe?

I've got the 2.3.0-rc1 version and I see the option "Allow moving categories" here, but I have it unchecked and still I'm not able to make two categories with the same name in the separate and different blogs :/ [well, not exactly separate - one of them is a "sparse" translation of the second one, therefore I want them to have the same category names allowed, like "DirectX", "SDL" etc.]. Does this patch will help me with that?

6 Jan 02, 2008 11:22

I think it is safe.
But I did not test. But you can.
The easy way to do so is to make a backup of your database in phpMyAdmin and install this database in a new database. So now you have two identical databases. If you also make a copy from the files in a separate folder, you have a perfect test setup. Do not forget to point /conf/_basic_conf.php to the testcopy of the database rather than the original production one.

This is not because I do not trust jarvil, but in general should you do anything tricky in a test setup first before you deploy to your production site. In the chat section there is a topic about setting up a local testsite with Wamp or Xampp.

Good luck

7 Jan 03, 2008 04:19

I think this topic is a bug for two reasons, though the second is easily and properly dismissed when one considers all possible applications of b2evolution.

Adding content to this new field is absolutely required, which is another way of saying it doesn't default to something if you don't fill it in. Previously existing categories default to "catNN", but a new category doesn't default to anything.

No matter what your blog settings, you have to provide a unique catURL. As we've seen, the problem with allowing non-unique category URLs is when you have the same category URL in multiple blogs. How then would b2evolution resolve a URL to the 'correct' category ID?

OTOH this is a new feature, so giving some time to work out the kinks in a "RC" release makes sense yah?

8 Jan 03, 2008 08:10

One reason why category URLs must be unique is because the Post System is attached to the Category System.

You can try it yourself by moving a category from one blog to another, all the posts under that category are carried over. I think this system was explained way back with b2e 0.xx versions. (Yah, years ago..)

The posts are not really attached to the "blogID" but to the "Main Category". b2e relies on the categories, so if two categories share the same URL, b2evolution will be confused where the post is located.

At least that's how I understood it.
However, it re-coding is possible, say for b2e version 3.x, I will strongly suggest making the post system independent, which will enable b2evolution to make the category system centralized. 1 long list of categories for all blogs. With checkboxes on each to determine which categories are available for which blogs. This method will also open a whole new set of features and possibilities like being able to show "all posts" in "all blogs" if you load the category URL. (That also adds usefulness to the category system.) This same idea can also be applied to the new tag system.

Anyway, hehe.. ;)

9 Jan 03, 2008 09:21

Yeah Laibcoms has it right: posts are actually attached to categories, which are also attached to blogs. We think of it as "posting in a blog and a cat or two or three" but we're really posting in a cat or two or three that all happen to be associated with a blog ... or two or three. Been that way since at least 0.8.6.2, and structurally it makes a heck of a lot of sense.

The thing with this new feature is that all the possible permutations available without editing files need to be workable. More importantly, they need to be workable now AND when I change whatever settings I feel like changing next week. Unfortunately the same situation applies if b2evolution had a "master list of cats with checkboxes": how do you take all possible URLs and find the right blog for a category named 'whatever'? You can't tell each blogger they can't use a cat name someone else used, and you don't want a link to any given category name resolving to posts across multiple blogs that happen to have a matching category name.

Maybe the answer is to simply use the cat name as the cat URL and add another detail when crafting the URLs with cat URL in them? Something like "blahblah.com/cat-name/NN/blahblah" where NN is the cat number?

I just wish it would default to something reasonably friendly instead of "cNN" for existing cats and "nothing so deal with it" for new cats. I have one blog with around 90 cats in them, and they all have meaningless category URLs. :(


Form is loading...