1 tselliott Oct 14, 2008 18:21
3 tselliott Oct 14, 2008 23:50
Hmmm. It seems that no matter how you have your URLs setup, the only important bit of information is the URL slug. For example, I visited two posts on EdB's blog(s):
Post 1: http://wonderwinds.com/hackblog.php/2008/08/17/image-list-widget-hack-for-2-4-2
Post 2: http://wonderwinds.com/weblog.php/2008/10/03/nanowrimo
Then I took the slug from post 1 and put it on the end of post 2, like this:
http://wonderwinds.com/weblog.php/2008/10/03/image-list-widget-hack-for-2-4-2
Instead of throwing up an error page or something (that post doesn't exist in the weblog blog), it ignored everything except for URL slug, and went to Post 1.
For a more extreme example, I'll put the domain name, any blog, some random stuff, and then finish it up with a slug:
http://wonderwinds.com/flightblog.php/this/is/a/test/whydoesitwork/123456/nanowrimo
Judging from this behavior, it makes sense why the URL slug must be unique. However, I'd still prefer if slug duplication was allowed, at least between different blogs.
What is the protocol for filing a feature request? Thanks.
4 sam2kb Oct 15, 2008 01:03
Welcome to the forums.
I think it's a lot easier to use one b2evo install for English and another one for Russian posts. Then you can use the same url titles in posts, and even hard-code the default locale.
Good luck
5 tselliott Oct 15, 2008 02:20
Is that the recommended approach? I was hoping to avoid managing two b2evo installs.
Do you have a link to any public sites you've set up using this approach?
6 sam2kb Oct 15, 2008 02:35
I don't know such sites, but it doesn't mean you can't make one yourself ;)
But if you still want to stay with one b2evo install you can add something like _ru to Russian url titles.
7 tselliott Oct 15, 2008 02:39
Yeah, I was thinking of appending _ru or something like that so the url titles will still be unique.
Any ideas about getting the current url in php so I can tack this on?
8 sam2kb Oct 15, 2008 02:46
Try this
regenerate_url( 'blog,title,more,c,tb,pb,locale' )
9 sam2kb Oct 15, 2008 02:57
Here's the function itself
/**
* Regenerate current URL from parameters
* This may clean it up
* But it is also useful when generating static pages: you cannot rely on $_REQUEST[]
*
* @param mixed|string (delimited by commas) or array of params to ignore (can be regexps in /.../)
* @param array|string Param(s) to set
* @param mixed|string Alternative URL we want to point to if not the current URL (may be absolute if BASE tag gets used)
* @param string Delimiter to use for multiple params (typically '&' or '&')
*/
function regenerate_url( $ignore = '', $set = '', $pagefileurl = '', $glue = '&' )
10 tselliott Oct 15, 2008 03:11
sam2kb wrote:
Try this
regenerate_url( 'blog,title,more,c,tb,pb,locale' )
I'll give that a try. Is this documented anyplace? For example, I'm not sure how to get the blog and title of the post I'm currently on.
11 sam2kb Oct 15, 2008 05:44
I don't think it's documented.
Current post url and title
echo $Item->get_permanent_url();
echo $Item->title
Current blog url and name
echo $Blog->gen_blogurl();
echo $Blog->name
Current category url and name
$ChapterCache = & get_Cache( 'ChapterCache' );
$Chapter = & $ChapterCache->get_by_ID( $GLOBALS['cat'], false );
echo $Chapter->get_permanent_url();
echo $Chapter>get( 'name' );
12 tselliott Oct 15, 2008 12:15
Thank you very much for those tips! I've got it to switch between the appropriate blog now. The last bit of icing on the cake would be to preserve the post the viewer is on if s/he is on a post. I still can't figure out how to do this.
$Blog->gen_blogurl() gives me full URL of the blog and $Item->get_permanent_url() gives me the full URL of the first post displaying.
What I would really like is to only use the $Item->get_permanent_url() when a viewer is viewing a specific single post. For completeness, I suppose I should trap for date archive url, category url, and tag page url as well.
So back to the original question, is there anyway to get the exact URL address that is showing in a browser's address bar? If I could get that, I could whip together some logic to take care of all the specific cases.
13 sam2kb Oct 15, 2008 15:37
This gives you the right url you can use, but may add additional params to url
regenerate_url( 'blog,title,more,c,tb,pb,locale' )
You can also try this
echo $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
One further question. I wrote that the URL "slug" or URL "filename" was the same for the post in the Russian and English blogs. However, it looks like b2evo prevents me from using the same slug. This would make sense if the two posts were in one blog, but they are in two separate blogs. Is there some setting that I am missing to allow me to have a test-post-1 slug in blog1 and a test-post-1 in blog2?
Thanks!