Recent Topics

1 Nov 23, 2006 00:55    

This hack was initially added to a 1.8.2 installation that has been successfully migrated to 1.8.5, but this post about this hack was written based on 1.8.2, so don't be too surprised if the parts you are supposed to find are slightly different in 1.8.5.

ALWAYS BACKUP YOUR FILES AND DATABASE BEFORE HACKING!!!

****************************************************************

Files to Edit:
inc/misc/_template.funcs.php
inc/MODEL/collections/_blog.class.php
skins/your_skin/_main.php

Files to Create:
skins/your_skin/_something.php

****************************************************************

OPEN inc/misc/_template.funcs.php

FIND

		case 'msgform':
			// We are requesting the message form:
			$r[] = T_('Send an email message');
			break;

		default:
			// We are displaying (a) message(s)...



REPLACE WITH

		case 'msgform':
			// We are requesting the message form:
			$r[] = T_('Send an email message');
			break;

//
// MOD: Add a disp=something page
//
		case 'something':
			// We are requesting the something page:
			$r[] = T_('Title For Something');
			break;
//
// END MOD: Add a disp=something page
//

		default:
			// We are displaying (a) message(s)...

****************************************************************

OPEN inc/MODEL/collections/_blog.class.php

FIND

				else
				{
					return '';
				}


			default:
				// All other params:



REPLACE WITH

				else
				{
					return '';
				}

//
// MOD: Add a disp=something page
//
			case 'something':
				return url_add_param( $this->gen_blogurl( 'default' ), 'disp=something' );
//
// END MOD: Add a disp=something page
//


			default:
				// All other params:

****************************************************************

OPEN skins/your_skin/_main.php

FIND

		case 'subs':
			// this includes the subscription form if requested
			require( dirname(__FILE__).'/_subscriptions.php');
			break;
	}
	// ------------------- END OF INCLUDES FOR LAST COMMENTS, ETC. -------------------



REPLACE WITH

		case 'subs':
			// this includes the subscription form if requested
			require( dirname(__FILE__).'/_subscriptions.php');
			break;

//
// MOD: Add a disp=something page
//
		case 'something':
			// this includes the something page if requested
			require( dirname(__FILE__).'/_something.php');
			break;
//
// END MOD: Add a disp=something page
//
	}
	// ------------------- END OF INCLUDES FOR LAST COMMENTS, ETC. -------------------

In the same file create a link to the something page:
(You can add the link anywhere you like. This example adds the link to an unordered list found in the 'custom' skin.)

FIND

			<li><a href="<?php $Blog->disp( 'dynurl', 'raw' ) ?>"><strong><?php echo T_('Recently') ?></strong></a> <!-- <span class="dimmed"><?php echo T_('(no cache)') ?></span> --></li>
			<li><a href="<?php $Blog->disp( 'lastcommentsurl', 'raw' ) ?>"><strong><?php echo T_('Last comments') ?></strong></a></li>
		</ul>



REPLACE WITH

			<li><a href="<?php $Blog->disp( 'dynurl', 'raw' ) ?>"><strong><?php echo T_('Recently') ?></strong></a> <!-- <span class="dimmed"><?php echo T_('(no cache)') ?></span> --></li>
			<li><a href="<?php $Blog->disp( 'lastcommentsurl', 'raw' ) ?>"><strong><?php echo T_('Last comments') ?></strong></a></li>
<?php // MOD: Add a disp=something page ?>
			<li><a href="<?php $Blog->disp( 'something', 'raw' ) ?>" title="link to something page"><strong><?php echo T_('Something') ?></strong></a></li>
<?php // END MOD: Add a disp=something page ?>
		</ul>

****************************************************************

CREATE skins/your_skin/_something.php:
This page needs to be a php file, and should take advantage of b2evolution's file security:

<?php 
/**
 * Begin your _something.php file with a comment to remind yourself what the page is all about.
 */

if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
// ======== START OF MAIN AREA ======== ?>

<div class="bPost">
<h3 class="bTitle">This is your something page!</h3>
<div class="bText">
<p>Here we see good old fashioned text.  Remember to tag up your html as you would have way back in the days of hand coded webs!</p>
<p>Notice how we have a "&lt;div="bPost"> and "&lt;/div>"?  The rest of b2evolution will, in most skins, give you a bPosts div and it's closing tag</p>
<p>View your source code if the page is not what you want, as it might be that your skin is creating divs differently than the 'custom' skin.  You will need to match the divs and classes your skin uses to make a post look the way it looks.</p>
</div>
</div>

<?php 

?>

2 Nov 23, 2006 12:29

Can you give us a quick summary of what it does and why we would want to apply it ;)

3 Nov 23, 2006 12:45

balupton wrote:

Can you give us a quick summary of what it does and why we would want to apply it ;)

Exactly my idea ;)

4 Nov 23, 2006 14:02

I can see what EdB is on about.
It's just a simple way to generate a page within your blog that could contan anything you might deliver via a normal HTML page.
Photogallery, Code examples, etc etc

I posted a version of this a while ago as a way to display an ABOUT page
http://forums.b2evolution.net/viewtopic.php?t=9140

5 Nov 23, 2006 17:59

Exactly, only I wasn't aware that a hack for this was already out there.

6 Dec 04, 2006 18:08

i've b2evo 1.8.1, you know if this hack work also with this version?

7 Dec 04, 2006 23:15

Giast wrote:

i've b2evo 1.8.1, you know if this hack work also with this version?

I have had no problems with any upgrades from 1.8.0 up to the current 1.9.1

Just remember to double check the effected files if you do an upgrade..

Files to Edit:
inc/misc/_template.funcs.php
inc/MODEL/collections/_blog.class.php
skins/your_skin/_main.php

8 Dec 05, 2006 01:15

John is on the money here. The hack SHOULD be able to work with 1.8.1, but keep an eye out for things that don't seem the same between the hack instructions and your actual files.

9 Mar 12, 2007 22:37

What about 1.9.2? I doesn´t get this to work with the current version of b2evolution... :(

11 Mar 13, 2007 00:42

Actually neither of these hacks will work with 1.9.* straight out of the box because the switch(disp) bit no longer exists in skins/skinname/_main.php file. Someone wrote in a thread here that this version can be used pretty much as-is except you put the "something" file in the skins/ folder instead of skins/skinname/. I haven't done it yet to be sure because I haven't upgraded my 1.8.7 installation yet. That'll happen Wednesday morning so that's when I'll know how it goes.

12 Mar 13, 2007 05:58

I found how to make this work with 1.9.*
just open _dispatch.inc.php in \blogs\skins\
and find

$disp_handlers = array(
			'arcdir'   => '_arcdir.php',
			'comments' => '_lastcomments.php',
			'msgform'  => '_msgform.php',
			'profile'  => '_profile.php',
			'subs'     => '_subscriptions.php',
		 );

add

'something' =>'something.php'


into array()

that is all

13 Mar 13, 2007 06:52

Thanks xxxxusky
That must a new file... I didn't even know it existed :)
Sure makes life easier

14 Mar 13, 2007 14:50

xxxxusky wrote:

I found how to make this work with 1.9.*

Cool - thanks. Hey now everyone knows!

18 Mar 14, 2007 17:14

I don't think that's the answer. I did this hack with the 1.9.* corrective action and it failed. It gave me the "undefined disp" page using FireFox. So I tinkered. This makes no sense at all, but my skins/_dispatch.inc.php had this in it:

if( $disp != 'posts' && $disp != 'single' )
{ // We must display a sub template:
	$disp_handlers = array(
			'arcdir'   => '_arcdir.php',
			'comments' => '_lastcomments.php',
			'msgform'  => '_msgform.php',
			'profile'  => '_profile.php',
			'subs'     => '_subscriptions.php',
			'something' => '_something.php',
		);

	if( empty( $disp_handlers[$disp] ) )
	{
		debug_die( 'Unhandled disp type ['.$disp.']' );
	}


That failed, but it worked worked when I changed it to this:

if( $disp != 'posts' && $disp != 'single' )
{ // We must display a sub template:
	$disp_handlers = array(
			'arcdir'   => '_arcdir.php',
			'comments' => '_lastcomments.php',
			'msgform'  => '_msgform.php',
			'profile'  => '_profile.php',
			'something' => '_something.php',
			'subs'     => '_subscriptions.php',
		);

	if( empty( $disp_handlers[$disp] ) )
	{
		debug_die( 'Unhandled disp type ['.$disp.']' );
	}

All I did was copy the line for 'subs' and changed it to 'something' (plus removed the extra spaces before the => thing), but it failed. I then moved the 'something' line to above the 'subs' line and it worked. Hmmm...

By the way I edited the initial post to correct 2 errors: first I noticed I commented out the ending ?> in one of the hacked in bits. I also just noticed my sample _something.php page will not display as-is because I use < to identify a div in the page, but it gets interpreted that way, so I replaced it with &lt;

Also, the hack originally worked with _something.php in your skins/yourskin/ folder, the corrective action said it needed to be in skins/ but I've found that it does not: it works with it in the actual skin, but only after tinkering with the _dispatch.inc.php file.

19 Mar 14, 2007 18:24

They link to "index.php?disp=foo" which will be interpreted as domain.com/skins/<skin>/index.php?disp=foo which is what is producing their 404 error ;)

¥

20 Mar 14, 2007 21:32

Yes you're right. I didn't catch that detail. haRacz has the hack done incorrectly. The right way to do that bit is either with a full URL or with <li><a href="<?php $Blog->disp( 'something', 'raw' ) ?>"><strong><?php echo T_('Something') ?></strong></a></li>.

21 Jul 18, 2007 01:15

john and edb,

once this piece is added, how would i integrate it with the admin so a user could enter the info without going through and editing files directly.

i have multiple bloggers and want them to be able to update it without it going through me :-)

22 Jul 18, 2007 01:25

adriscoll that would be an awesome feature. I think I read something about how non-blog pages are part of the future, but for right now I don't think it's possible. Something about not having hooks where you would need them for a plugin to make it happen. Therefore it would be a creative hack on top of a minor hack.

23 Jul 18, 2007 02:33

edb,

is their a way to flag a posting so that i could have my bloggers just put some info in a posting and have it reside in a single spot on the site.

i am posting this on the main forum as well.

cheers

24 Jul 18, 2007 16:52

Please don't double post stuff.

25 Jul 31, 2007 18:31

is there a way to incorporate the editing of the "something" page in the admin? if so, what files need to be effected?

26 Aug 06, 2007 17:25

It is possible to hack it in, but it would not be easy. I also think it will not carry forward to the 2.0 release.

Basically this is where you should look. The "templates" tab allows you to edit files in the skins/custom folder, so if you could make that edit files in the skins folder you would be able to edit the something page via the templates tab. It would not be pretty or friendly, but it would be "doable".

I think when 2.0 comes out I will revisit this hack as I have quite a few applications for this. Assuming I need to, meaning assuming 2.0 does not have "non blog post page" support, I will focus on a method to make easy and friendly access to this type of thing via the back office. AFAIK it would still be a hack, but the hack would be to add hooks that support a plugin for this purpose.


Form is loading...