Recent Topics

1 Jun 08, 2014 06:33    

Howdy!

My blog is an art blog with some explicit artworks. The explicit artworks are supposed to be limited to the Gallery (meta)\Sealed Section category so people can choose to see them or not.

The only problem is that the front page defaults to all posts. I completely understand why that is, but of course it defeats the purpose of having the Sealed Section.

I have used hacks to make other places difficult to access - for instance, All doesn't show in the category list (display:none) and the meta categories have the event pointer turned off so they're just headings. It's not 100% foolproof, but it doesn't need to be - someone working that hard to get to it can't say they got to it unawares. I just want to avoid unwitting casual stumble-ins.

I would consider any of the following acceptable outcomes:

1. index.php, if not redirecting to a specific post/cat/whatever, defaults to showing one of my meta categories instead of All.
2. As above, but defaults to showing a specific post. (I have a welcome post that would be fine).
3. I find a way to suppress certain posts from being shown under All. (eg - hack the PHP to filter posts with the Sealed Section category out).

I have a fair entry-mod-level understanding of B2E and am comfortable with PHP but I don't know where to look for some of this. I got as far as _blog_main_inc.php for the redirect but I didn't fully understand how it works.

If it helps, you can see it live at www.[my username backwards].com - the art posts are all private until I can work out a solution but you'll probably be able to see what I'm trying to do.

Can anyone suggest a way to do this?

Many thanks

2 Jun 08, 2014 15:20

Hello @deslea,

Did you considered to use the parameter $cat to exclude your Sealed Section category?

Basically, you may add $cat = -categoryID to the stub file (index.php in your case), in order to exclude that category from the main stream (more info in this page: http://b2evolution.net/man/url-params).

3 Jun 08, 2014 16:21

Hi @mgsolipa

Thank you, that's exactly what I wanted! I'm trialling using it to limit the main stream to just my welcome message (which has a cat of its own) for now, but I can see a few different ways I can use it. Thanks so much!

Cheers - Deslea

4 Jun 08, 2014 17:57

Just a follow-up - I had to stop doing this because it made the Permalinks in the Sealed Section fail. So it's back to the drawing board!

5 Jun 08, 2014 21:47

I've got a fix for the permalinks problem. (It occurred to me later that this might be a skin-specific problem, too - I'm using Custom).

Set $cat = n; in index.php (where n is the id for the category to suppress). This suppresses the category in the main stream on index.php, as expected.

In _blog_main.inc.php, go to about line 137, just under:

	if( preg_match( $blog_baseuri_regexp, $ReqPath, $matches ) )
	{ // We have extra path info
		$path_string = $matches[2];

B2evolution has pulled out most of the originating URL for us so we can figure out whether this is a single post that should have the category setting put back. (I tried using $_SERVER earlier on but it didn't populate for some reason). Add the following:


// Fragment to allow a suppressed category for individual posts (otherwise permalinks in the suppressed category fail).

	$trim_ReqPath = str_replace("/blog/index.php", "", $ReqPath);  
            // Strips off the "real" URL before the slugs. You may need to edit the path.
	$url_trimmed = trim($trim_ReqPath, "abcdefghijklmnopqrstuvwxyv-"); 
            // Takes the part after index.php and strips off everything but the forward slashes
	IF ($url_trimmed == "/") { $url_type = "post"; } 
            // Checks for a single forward slash remaining- this suggests a post
	       // This is not foolproof - individual malformed category URLs may also be detected here
            // However, these are not affected by the $cat setting
	IF ($url_type == "post") {
	$cat = '';
            // Overrides the $cat = n that applied to index.php
	}


Form is loading...