1 jibberjab Sep 14, 2005 06:51
3 jibberjab Sep 14, 2005 17:48
Thanks for the thumbs-up on the skin design. I'm considering submitting it to the repository, but there are a few more things I need to add to it still, and I'm also thinking about working on making it Section 508 compliant which, I think, would be a good thing.
The reason you're not seeing the error is because I was referencing a blog I set up on a test site. The one you looked at is 0.9.0.10, the test one I'm working on is 0.9.0.12. I've been working on making sure the darkling skin you looked at is 100% between the two versions, at the same time as I'm working on a variant of darkling which will be called brightling. After that I'm going to design a pack of seasonal CSS files based on the same skin layout (autumnling, winterling, springling and summerling). However, those will just be alternate CSS files, so I'm working on finalizing _main.php first...
Now, as for the code you suggested... I added the section to _item_class.php and got the following results:
In the main blog, at the top of each post, I get something similar to this:
08 September 2005
07:42:30 pm, Categories:
categoryIDs is :Array
Array
(
[0] = > 1
[1] = > 4
[2] = > 11
)
name_of_first_cat, name_of_second_cat, name_of_third_cat
However, on the stats page, I get the same error as before:
09/08/05 Extended post with no teaser in
categoryIDs is :
Warning: Invalid argument supplied for foreach() in /path/to/the/blog/b2evocore/_class_item.php on line 316
Right now I'm using your suggestion for the conditional statement, but only wrapped the "in php $Item->categories()" piece, so that when someone is viewing the stats page it still shows the recent posts, just doesn't try to show what cats they were posted in. I think I might even leave it that way and come back to the IN CATEGORIES problem when I have a little more time. For now, they still show in the main blog pages which is more important to me anyway.
If I can figure out how to change the display to wide view, I can get rid of the sidebar completely on the stats page, something like this:
<?php if( $disp != 'single' ) {
echo '<div id="wrapper">';
} else {
echo '<div id="wrapperwide">';
} ?>
I have #wrapperwide in the stylesheet set to show:
#wrapperwide #sidebar {
display: none;
}
so the sidebar disappears in the wide view. If I can make the stats page appear in wrapperwide instead of wrapper, I can just get rid of the sidebar completely on the stats page, which is another option I'm considering.
Can I just do this: (?)
<?php if( $disp != 'single' ) {
echo '<div id="wrapper">';
} else {
echo '<div id="wrapperwide">';
} ?>
<?php if( $disp != 'stats' ) {
echo '<div id="wrapperwide">';
} else {
echo '<div id="wrapper">';
} ?>
Sorry for the long post.
jj.
4 edb Sep 14, 2005 18:21
The first problem first: Now we know that when you're on the stats page $this is not set, so it's killing that function. Where you see "categoryIDs is :" with no value is why I say that. Bummer! Your solution is effective, but you might want to play with [url=http://wonderwinds.com/hackblog.php/2005/01/28/recent_posts_hack_for_b2evo]this hack[/url] at your convenience. It has an option to identify the category and another to link it, but I can't say that it will for sure work on the stats page.
The second thing isn't that hard, but personally I'd not go with the "none" thing. AFAIK it'll still be sending the content - just using CSS to not display it. That means page load time is longer than the displayed content deserves, and someone who disables your CSS will see that which you didn't want on the page. I think you can do it with PHP though. Something like this maybe:
<?php if( ($disp != 'single') || ($disp != 'stats' ) ) {
echo '<div id="wrapper">';
} else {
echo '<div id="wrapperwide">';
} ?>
Doesn't that take away . . . oh never mind. With bloglinks in the header you don't lose critical navigation from the sidebar.
EDIT: of course you'll have to do a similar trick to block the sidebar. Something like "If disp != stats" wrapped around the whole sidebar, but you probably got the idea.
OFF TOPIC: I wish I didn't dump my zigzag skin. It used like 8 style sheets and a couple of randoms (and a hell of a lot of hackage) to have (a) different "painful to the eyes" color schemes and (b) the sidebar on either the right or left. No matter where the sidebar showed up, it alternated as it went down the page, meaning short or long posts further twisted the overall flow of the page. Finally, going to a single post page would (of course) flip the sidebar randomly and also randomly select the content in the sidebar. Irrational exuberance taken to an extreme, completely unpredictable layout, grotesque to behold, but totally valid code. I miss that skin :'(
5 jibberjab Sep 14, 2005 18:31
I agree, using display:none does use more processing time than is probably necessary, but as my CSS ability is greater than my PHP ability, it was a good (if temporary) solution.
Using the conditional statement you listed above comes to mind.
Perhaps:
1. remove the display:none from the CSS.
2. Leave the if/else for wrapper/wrapperwide, so the main block still gets ID'd properly.
3. wrap the entire sidebar in a conditional statement so that when the main wrapper is ID'd as "wrapper" it displays the sidebar, but when the main wrapper is ID'd as "wrapperwide" it does not.
Problem is, as I said, my php skills aren't quite there yet.
jj.
6 edb Sep 14, 2005 18:47
All the regular page stuff up until your main posts div starts, then
<?php if( ($disp != 'single') || ($disp != 'stats' ) ) {
echo '<div id="wrapper">';
$show_sidebar = true;
} else {
echo '<div id="wrapperwide">';
$show_sidebar = false;
} ?>
Now your entire posts loop all the way down to the sidebar, then
<?php if ( $show_sidebar ) { // only show if div is regular wrapper ?>
Now all the stuff for the sidebar, then
<?php } // end the if that hides the sidebar ?>
Finally your footer if applicable and any closing divs for, you know - like "wrapper" divs or whatnots.
I'm pretty sure that'll hook you up.
7 jibberjab Sep 14, 2005 18:52
Sweet. I'm going to give this a try later this afternoon.
jj.
8 jibberjab Sep 22, 2005 04:35
Ok, I did some more looking into this problem... The error I was originally seeing:
09/08/05 Extended post with no teaser in
Warning: Invalid argument supplied for foreach() in /path/to/the/blog/b2evocore/_class_item.php on line 309
doesn't only occur on the stats page. It also occurs when clicking on a category name. If my current list of recent posts shows:
DATE PostTitle1 in CategoryA
DATE PostTitle2 in CategoryA
DATE PostTitle3 in CategoryB
DATE PostTitle4 in CategoryC
and I click on the link for CategoryA in the sidebar, then I see only the posts for CategoryA (obviously). In that situation, any posts that are in the category which I drilled down into, DO NOT get the error in the "Recent Posts" list. Any posts in the "Recent Posts" list which are NOT in the category I drilled down into, DO have the error.
jj.
9 jibberjab Oct 05, 2005 20:27
EdB,
I finally got around to implementing your code suggestion to remove the sidebar completely, rather than using display: none in the CSS. Your code example above shows:
<?php if( ($disp != 'single') || ($disp != 'stats' ) ) {
echo '<div id="wrapper">';
$show_sidebar = true;
} else {
echo '<div id="wrapperwide">';
$show_sidebar = false;
} ?>
With the OR statement in there, the code doesn't seem to work (i.e. it still shows the sidebar and doesn't rename the div to wrapperwide.). If I remove the
|| ($disp != 'stats'))
piece, it works properly for the single view... I've tried stacking them into two separate if statements but no luck.
jj.
10 edb Oct 05, 2005 20:38
I hate oring a pair of nots. Try sledgehammering it maybe.
<?php if( $disp != 'single' ) $whatever = true;
if( $disp != 'stats' ) $whatever = true;
if( $whatever ) {
echo '<div id="wrapper">';
$show_sidebar = true;
} else {
echo '<div id="wrapperwide">';
$show_sidebar = false;
} ?>
11 jibberjab Oct 05, 2005 21:39
That's kinda similar to what I tried... no joy.
jj.
12 edb Oct 05, 2005 21:43
Sorry, but I'm out of ideas. Since moving to dawn I don't have stats displayed anymore, and therefore can't even practice stuff about the stats section. In a way I miss some aspects of public stats, but I don't miss how it drew spammers like a magnet.
13 jibberjab Oct 05, 2005 23:31
It's cool. I think I'm probably just going to make the stats viewable only to users who are logged in. Maybe that will deter some of the spam attempts.
jj.
Nice skin. Validates too - woohoo! Are you gonna, or have you already submitted it to the skins site? Valid skins rock.
What I think is happening is $this doesn't know what it is when you're on the disp=stats page. Actually it could also be because $Item is confused. I picked $this because that's what's right before the line referenced in your error. Not sure - just took a quick look at the stock files and jumped to that conclusion. Oh I'm guessing you're either hiding that block to only logged in people or have removed it from your _main till you get this straightened out.
Either way, I can offer a simple work-around if you don't mind. Take the entire "recent..." block and wrap it in a conditional statement. Something like this:
That's how the stats block is kept off the stats page in the custom skin, so it'll fo sho work for your "recent..." block as well. If you really truly MUST have this on that page then give this a shot and see if it helps. The stock file around line 309 goes like this:
Cool, so see where it's going belly up with a bit of cheating.
That way you're not showing your visitors any of the icky guts while you're troubleshooting, and you'll see whatever it is that categoryIDs is. You can then compare a multi or single post page with the stats page, and maybe get a grip on what's happening. Nice little cheat there eh? Show the guts to logged in people only? I do it that way because I'm my only blogger. It can be tweaked to say "if logged in then see if it's ID #1 and if so show the guts", but I don't have an example of that handy. I got so much crap hiding inside "am I logged in" I sometimes have to go to my web in IE to see what visitors see. I'm assuming I have visitors, so lets not have any comments that break my bubble, please ;)