Recent Topics

1 Mar 17, 2004 11:48    

Hi folks

I was looking for a way to make a sort of editorial on top of my blogs articles for one of my blogs, this would be a description of the next articles of the page, or a sort of introduction.

I can't make an article staying on top forever ... unless changing its date to today everyday ... and it's a bit stupid too

I found a way to display an article, maybe a bit a dirty way ... let me know

I created another blog # 11 called edito, not displayed on main page blog list
using :

	 if( $curr_blog_ID == 11 ) continue; // Hide blog 11...

after that
i got a few new files to do
1 - /edito.php
2 - /skins/_edito.php
3 - /skins/custom/_edito.php

File 1 is not interresting and nothing particular to do with it ...

File 2 looks like this
(it's a dirty copy/paste of blogroll.php + changes in var name)

?php
	/*
	 * This is the template that displays the edito
	 *
	 * This file is not meant to be called directly.
	 * It is meant to be called by an include in the _main.php template.
	 */
	if(substr(basename($_SERVER['SCRIPT_FILENAME']),0,1)=='_')
		die("Please, do not access this page directly.");
	# maximum number of edito entries to display:
	if(!isset($edito_limit)) $edito_limit = 1;
	# global edito delimiters:
	if(!isset($edito_main_start)) $edito_main_start = '';
	if(!isset($edito_main_end)) $edito_main_end = '<br />';
	# Category delimiters:
	if(!isset($edito_catname_before)) $edito_catname_before = '';
	if(!isset($edito_catname_after)) $edito_catname_after = '<br />';
	if(!isset($edito_catlist_end)) $edito_catlist_end = '';
	# Item delimiters:
	if(!isset($edito_item_before)) $edito_item_before = '';
	if(!isset($edito_item_after)) $edito_item_after = '';

=> added this :	$edito_blog = 11;  // i had to set it to 11 in a stupid way, don't know if there is better way to do it, blog 11 is the edito (could be usefull when i want to display edito 1 on blog 1, edito 2 on blog 2 ....  )

	// Load the edito blog:
	$editoList = new ItemList( $edito_blog, array(), '', '', '', $edito_cat, $edito_catsel, '', 'ASC', 'category title', '', '', '', '', '', '', '', '', $edito_limit, 'posts', $timestamp_min, $timestamp_max );
	
	// Dirty trick until we get everything into objects:
	$saved_blog = $blog;  
	$blog = $edito_blog;

	// Open the global list
	echo $edito_main_start;
		
	$previous_cat = '';
	$edito_cat = '';
	while( $editoList->get_category_group() )
	{
		// Open new cat;
		//echo $edito_catname_before;
		//the_category();
		echo $edito_catname_after;
		
		while( $editoList->get_item() )
		{
			echo $edito_item_before;
			the_title(); 
			echo ' ';
			the_content( T_('more'), 0, '', '', '[', ']' );	// Description + more link 
			?>
			<?php
			echo $edito_item_after;
		}

		// Close cat
		echo $edito_catlist_end;
	}
	// Close the global list
	echo $edito_main_end;
	
	// Restore after dirty trick:
	$blog = $saved_blog;		
?>

File 3 looks like this :



<?php
	/*
	 * This is the template that displays the edito
	 *
	 * This file is not meant to be called directly.
	 * It is meant to be called by an include in the _main.php template.
	 */
	if(substr(basename($_SERVER['SCRIPT_FILENAME']),0,1)=='_')
		die("Please, do not access this page directly.");
		
	# maximum number of edito entries to display:
	if(!isset($edito_limit)) $edito_limit = 20;
	# global edito delimiters:
	if(!isset($edito_main_start)) $edito_main_start = '';
	if(!isset($edito_main_end)) $edito_main_end = '';
	# Category delimiters:
	if(!isset($edito_catname_before)) $edito_catname_before = '';
	if(!isset($edito_catname_after)) $edito_catname_after = '';
	if(!isset($edito_catlist_end)) $edito_catlist_end = '';
	# Item delimiters:
	if(!isset($edito_item_before)) $edito_item_before = '';
	if(!isset($edito_item_after)) $edito_item_after = '';

	/*
	 * This skin has no special formatting for the edito, so...
	 * However you can replace this file with the full handler (in /blogs) and customize it!
	 * all we want to do here, is call the default edito handler.
	 */
	require get_path('skins').'/_edito.php';

?>

Voila ...

I 'm not really good at programming, then i guess this code can be really tuned, cause i was really lazy in doing it ....
There could be also a stupid thing that must be solved, i have a blog # 11 called edito, that could contain several categories (cat1 cat2 cat3 ...) that would display edito1 on blog1, edito2 on blog2 and so on ...
Don't really know how to do it, i guess it's the $edito_cat that need to be linked with the blog number ?? but how ?

you can check this edito on my website : http://www.uisce.net
This edito will now only be displayed on http://www.uisce.net/irl.php (just over the list : Ireland articles available here :
· Glencolumbkille - Co Donegal · Donegal County · Mayo County · Kerry · Dublin · Derry · Connemara · Facts and Things ·
)

thanks for your feedback

NB : Thanks ashrobo

2 Mar 17, 2004 16:04

hi,
i haven't had the time to try the hack although that might do what i have been waiting to be done. just want to point out that your 2nd url is wrong, i believe it should read: http://www.uisce.net/irl.php.

cheers!
-ashrobo

3 Apr 24, 2004 02:03

Is there some reason why you can't use the blog description or blogroll for this purpose? It seems like you're making it harder than it has to be. Maybe I'm just missing something.

Isaac

4 Apr 24, 2004 10:24

I should try maybe you're right Isaac, I made things too copplicated maybe ;)
I guess the blogroll could be good, and it's maybe what i sort of recreated
The description is a good idea I'll look in this direction too
thanks

5 May 11, 2004 22:16

I finally did this using the long description field and it works rather easily.

<div class="bPosts">
<div class="LongDesc">
<p><?php bloginfo('longdesc', 'htmlbody'); ?></p>
</div>
<?php	// --- START OF POSTS ---


That shows where to put the div so it only shows up once, which is probably a no-brainer but I made a couple of guesses at it before it worked. You could use "bPost" and "bText" if you want, but I wanted it displayed with the page background color and no border so I made up the "LongDesc" class. I also have a random image that I float:left, hence the P tag.

It's at http://whitesandshanggliding.com/main.php for those interested in seeing it.

This way when the search engines cache the main page from each blog they get stable text at the top of the page in addition to the changing post content.

6 May 11, 2004 23:26

Yeah, EdB, you made me realize something.

The question isn't so much "How do you get a post to stay at the top?" as it is "How do you make the description look like a post?"

That shouldn't require any crazy hacks. Just a matter of setting up the skin/template to use the same XHTML and CSS for the description as it does for the posts. (Note: in different skins, the classes might not be "bPost", and the specific XHTML might be different, etc. The point is that it's done up like a post would be.) I do something like this on [url=http://isaac.beigetower.org/index.php?skin=autumn]my site[/url]. It's really just a stylistic question.

7 May 12, 2004 09:17

Thanks EdB !!!! :D
It's exactly what i was looking for, for a static description it's perfect, my only question now ;-) is how can we include a dynamic code into the description, but maybe I'm asking too much (the longdesc was maybe not aimed for that ?)
like the list of article on the top of the articles on this page :
http://www.uisce.net/irl.php

Thanks again

8 May 12, 2004 11:47

You mean include a php tag in there? If you do, then no, as far as I'm aware, it's pulled as plain text which is then parsed by the browser, not the server. If you mean dhtml or something, then I don't see any reason why you can't...

9 May 12, 2004 19:32

Graham is probably right about putting actual php content into the long description BUT you can put html in there. Browsers like html! I just added a link to the long description on a hidden blog and found that it works like you would expect. In other words: "<? php some_thing(param) ?>" will (probably) not work but "<a href="yourlink.php" title="whatever">Text<a/>" will work. That implies you can do all your div stuff and whatever else you like in the long description field and have it properly executed by the browser, but I'm only guessing - experimentation will hook you up on it.

Code is cool B)

10 May 12, 2004 19:39

Ah, now we're talking hacks.

Anyone know what we'd have to do to make a hack that would allow one to put PHP in the long description or blogroll fields?

I'm thinking you might be able to hack the functions that display the blogroll/longdesc to look for a specific tag, and then include a php file from somewhere. So you'd have something like this in your blogroll or longdesc field:

<!--phpinclude=somethingfunky.php-->

and then you could put all the code in the somethingfunky.php file.

When displaying these items, you could have the function split up the string based on the <!--phpinclude=...-->, and include whatever file is specified in the tag. Then you could easily replace the static blogroll with a tagboard, for example, without changing the skins at all.

The other option, to have PHP code directly inserted into the field, would be a little more complicated, since the functions just drop the data directly without parsing it. I think that you'd have to have a function that writes the data to a file, and then includes it, and that might be more tricky. For starters, you wouldn't want to have to write the include file every time, since that'd probably be pretty server-heavy. (PHP would have to read-parse-write-read-parse-output each time, instead of just read-parse-output.) Maybe it could dump the contents of the blogroll to a file when you change and save it, and then just save the name of that file to the database? Seems like that'd be getting more and more complicated...

Putting PHP in the static fields would be super-cool, IMO.

11 May 19, 2004 20:57

Has the topic of creating 'sticky' posts come up yet?

I think that fits more (and has more uses). Basically, it just a modification of the SQL querry to add a field in another orderby column. This way you can have post that introduces main categories, for instance.

12 May 19, 2004 22:18

[url=http://b2evolution.net/dev/todo.php/2004/05/16/p2673]Sticky Posts[/url] and [url=http://b2evolution.net/dev/todo.php/2004/04/13/p2217]extended categories[/url] are both on the [url=http://b2evolution.net/dev/todo.php]ToDo list[/url].

As I understand it:
Sticky post = a post that always shows up at the top, regardless of the date that it was posted.
Extended categories = ability to add an icon and description for each category. This could be used to show the "post that introduces main categories, for instance." - in the template or skin, you'd have a function to call the category description, but only if a single category is selected. (Somewhat like how single_cat_title() works now. Not sure if this fxn is deprecated or not, I'm still working on getting up to speed with all the changes.)

14 Apr 26, 2006 22:13

Hello !
I see it was long time ago
Is there any progress on "Extended Category" ?
I made some sort of hack for this (see my post at http://forums.b2evolution.net/viewtopic.php?t=852 )
but it would be better if I had not had to alter files in evocore I think. I'm not so familiar with complex OO structures (And paranoid about what security holes I can leave :) )
Now I'm going to "hack" for "extended category" feature at my site, but may be I missed it somewhere and I don't have to invent the bycicle ?

Thank you!

15 Apr 27, 2006 15:31

Adding EdS's snippet to one someone posted that just lets it appear on the Home page works well. You can also easily style it to look like a normal post using the ID's and Classes from your current CSS.

EG:

<div class="bText">
<?php
if( !$s && !$cat && empty($catsel) && !$m && $disp=='posts' && !$title && !$p )
{
  ?>
<p><?php bloginfo('longdesc', 'htmlbody'); ?></p>

 <?php
}
?>
</div>


Form is loading...