Recent Topics

1 Sep 26, 2006 08:50    

Can I change the blog number of an existing blog? That is, say I have a blog at index.php?blog=2..... is there a way I could change the "2" to a number like, say, "124"?

I have a blog I want to "move" so someone can't find it. XX(

2 Sep 26, 2006 09:52

Doing this manually would take forever, doing it automaticly has not been added.

What you could do instead... Is apply the hack [url=http://forums.b2evolution.net//viewtopic.php?t=8089]here[/url]. Then make it so it dies if they tried to access the blog you wanted via integer reference.

So instead of the lat part in the above hack, apply the following;

// ========================================================================================================== 
// START OF BALUPTON's URLNAME AND SHORTNAME HACK 

// Check if a specific blog has been requested in the URL: 
param( 'blog', 'string', '', true ); 

// If $blog is a number 
if( is_numeric($blog) ) { 
   // Make $blog's type a number 
   settype($blog,'integer');
   if ( $blog == 2 ) die; // you will need to change this
} else { 
   // Check for urlname, if not check for shortname, if not use the default value 
   $blog =   ($temp = $BlogCache->get_by_urlname($blog, false)) ? $temp->ID : 
         (($temp = $BlogCache->get_by_shortname($blog, false)) ? $temp->ID : ''); 
   unset($temp); 
} 

// END OF BALUPTON's URLNAME AND SHORTNAME HACK 
// ==========================================================================================================

That way people can only access the hidden blog by knowing it's shortname or urlname.

Btw you need a 1.8 release for this.

Edit: Whoops forgot to add the link to the hack...

3 Sep 27, 2006 00:06

You could do so with a few SQL queries.
Basically, you need to change the blog_ID in the evo_blogs table and simultaneously all the tables that refer to it.
See http://doc.b2evolution.net/DB_schema/ for the DB schema - there are 6 foreign keys (FK) for b2evo 1.8 (e.g. from T_coll_settings).

If you really want it, you should be done with 7 UPDATE queries - but seriously, that's not a very good way to "hide" it.. you probably want to setup authentication through HTTP in your .htaccess or something alike.

4 Sep 27, 2006 02:14

Cool, the hack sounds like it'd be perfect for my purposes... thanks so much! :)

Authentication is a little more than I need - I don't mind the world at large finding this blog, I'd just rather people I actually know weren't on it. :p The particular person who found it is not very computer saavy, so just changing the url should hopefully suffice.

5 Sep 27, 2006 02:33

Possibly a dumb question but... where do I specify the urlname and shortname for a blog?

6 Sep 27, 2006 02:35

Backoffice (admin) -> Blogs -> Click your blog, and will be in the first tab.

They will look like; my_blog_name or similiar.

7 Sep 27, 2006 02:52

Ahh, duh. :oops:

So.... is the "Full Name" tag the "urlname" then?

8 Sep 27, 2006 02:57

Url name is "URL blog name:" under "Blog URL parameters"

9 Sep 27, 2006 03:09

Hrmm my method would stop working as soon as the user clicks a link, as blog=urlname would switch back to blog=blogid, Blueyed can you provide a fix for this, i tried just overwriting the blog param before the skin gets displayed but i could not get that to work...

10 Sep 27, 2006 19:15

balupton, $blog probably got overwritten/re-typed to integer at the beginning of _blog_main.inc.php.

11 Sep 27, 2006 19:18

yeh i tried adding it before the event BeforeBlogDisplay, but yeh i don't think changing $blog would be a good idea anyway, so i think maybe add a new param called blogshortname that gets memorized, so before the die, we check if that is correct?

But i can never seem to get any params to memorize....

12 Sep 27, 2006 19:55

I'd go for updating the blog_ID in the DB tables.

(There's an option of param() to memorize them, but they only get re-used with regenerate_url())

13 Sep 27, 2006 20:12

Ok got it working, So apply the hack i mentioned earlier, and use the following instead.

// ========================================================================================================== 
// START OF BALUPTON's URLNAME AND SHORTNAME HACK 

// Check if a specific blog has been requested in the URL: 
param( 'blog', 'string', '', true ); 

// If $blog is a number 
if( is_numeric($blog) ) { 
	// Make $blog's type a number 
	settype($blog,'integer'); 
	if ( $blog == 2 && ( !isset($_SERVER['HTTP_REFERER']) || !strstr($_SERVER['HTTP_REFERER'],$baseurl) ) )
		die('Hidden blog');
} else { 
	// Check for urlname, if not check for shortname, if not use the default value 
	$blog =   ($temp = $BlogCache->get_by_urlname($blog, false)) ? $temp->ID : 
		 (($temp = $BlogCache->get_by_shortname($blog, false)) ? $temp->ID : ''); 
	unset($temp);
} 

// END OF BALUPTON's URLNAME AND SHORTNAME HACK 
// ==========================================================================================================

And change the $blog == 2 part to whatever the blog ID is, and it will all be good.

14 Sep 27, 2006 20:20

1/ create a new blog
2/ enable "moving chapters" (conf/admin.php or advanced.php)
3/ hit admin>[current blog] > categories and move them (complete with posts) to new blog

¥

15 Sep 28, 2006 01:50

I think the above needs a step 2.5 (or 1.5). In the same file - which is conf/admin.php - set $allow_cross_posting to 3.

So

$allow_cross_posting = 1;
/**
 * Moving chapters between blogs?
 *
 * Special value: NULL and we won't even talk about moving
 *
 * @global bool|NULL $allow_moving_chapters
 */
$allow_moving_chapters = false;


Becomes

$allow_cross_posting = 3;
/**
 * Moving chapters between blogs?
 *
 * Special value: NULL and we won't even talk about moving
 *
 * @global bool|NULL $allow_moving_chapters
 */
$allow_moving_chapters = true;


After moving the chapters (categories) you set these values back and you're done.

Oh and move your sub-categories first! In a recent version (and I don't know about the most recent release) if you moved a main category the sub-categories would get abandoned in no-blog land. They didn't get deleted, but they didn't follow the parent category either.

16 Sep 28, 2006 09:53

EdB wrote:

Oh and move your sub-categories first! In a recent version (and I don't know about the most recent release) if you moved a main category the sub-categories would get abandoned in no-blog land. They didn't get deleted, but they didn't follow the parent category either.

I forgot all about that bug :p I thought I'd cured it in cvs, but it looks like it never made it into either of the last couple of versions (although it is in version 2.0 .... so far) :cookie:

¥


Form is loading...