Duplicated rewrite rule?

3 views
Skip to first unread message

tinyau

unread,
Jul 23, 2007, 9:48:51 PM7/23/07
to habar...@googlegroups.com
I am using different permalink structure for posts and pages.  When I tried to use ->permalink to get the permalink of page but found the permalink structure is same as post.  After I checked function get_permalink() of post.php and found

      $content_type= Post::type_name( $this->content_type );
      return URL::get(
         array(
            "display_{$content_type}",
            'display_posts_by_slug',
         ),
         $this,
         false
      );

The rewrite rule name "display_{$content_type}" cannot be matched the existing rewrite rules.  It should be "display_{$content_type}_by_slug".  If I modified it to

      $content_type= Post::type_name( $this->content_type );
      return URL::get(
         array(
            "display_{$content_type}_by_slug",
            'display_posts_by_slug',
         ),
         $this,
         false
      );

Another question arise.  There are only two types in posttype table, i.e. 'entry' and 'page'.  Based on the above codes, 'display_posts_by_slug' will never be used. Why the same rewrite rule with 2 names 'display_entry_by_slug' and 'display_posts_by_slug' existed at the same time?  Is it the intended design or is it duplicated?

Thanks.

--
Cheers,
tinyau

Owen Winkler

unread,
Jul 25, 2007, 7:33:38 AM7/25/07
to habar...@googlegroups.com
On 7/23/07, tinyau <tinyau....@gmail.com> wrote:
>
> Another question arise. There are only two types in posttype table, i.e.
> 'entry' and 'page'. Based on the above codes, 'display_posts_by_slug' will
> never be used. Why the same rewrite rule with 2 names
> 'display_entry_by_slug' and 'display_posts_by_slug' existed at the same
> time? Is it the intended design or is it duplicated?

It could be just a typo, a small bug. I'm not sure anyone else is
using custom permalinks that are different between posts and pages,
which is perhaps why this hadn't been caught yet.

Owen

tinyau

unread,
Jul 25, 2007, 9:34:42 AM7/25/07
to habari-dev
On Jul 25, 7:33 pm, "Owen Winkler" <epit...@gmail.com> wrote:
>
> It could be just a typo, a small bug. I'm not sure anyone else is
> using custom permalinks that are different between posts and pages,
> which is perhaps why this hadn't been caught yet.

Is it appropriate to align the name of rewrite rules with name of post
type by doing the following actions?

1. Change get_permalink() function of post.php as

private function get_permalink()


$content_type= Post::type_name( $this->content_type );
return URL::get(
array(
"display_{$content_type}_by_slug",

),
$this,
false
);
}

2. Delete the rewrite rule 'display_posts_by_slug', rename all other
rewrite rules with 'display_posts_' prefix to 'display_entry_'

3. Change all the reference of affected rewrite rule to the new name?

---
tinyau

Owen Winkler

unread,
Jul 26, 2007, 9:21:20 AM7/26/07
to habar...@googlegroups.com
On 7/25/07, tinyau <tinyau....@gmail.com> wrote:
>
> Is it appropriate to align the name of rewrite rules with name of post
> type by doing the following actions?

This seems sane, though if it's possible and reasonable, I'd like to
be rid of the "_by_slug" postfix altogether, too.

Owen

tinyau

unread,
Aug 5, 2007, 9:30:50 PM8/5/07
to habar...@googlegroups.com
Patch made, see issue 350 (http://code.google.com/p/habari/issues/detail?id=350)

--
tinyau
Reply all
Reply to author
Forward
0 new messages