Recent Topics

1 Sep 23, 2011 02:03    

My b2evolution Version: 4.x

Ok, I've got several pages on my blog, and I do have a custom page template for them that works well. But one of the pages has a short list of random Javascript games that I've had forever. I was playing around and wanting to add some, which I can do through b2evo, but what I'd really like to do is make a simple database listing for them so I can add more in the future much eaiser. What I'd like to do, then, is in the page editor through b2evo either add the PHP I need to pull them, or have it include a seperate file. Any suggestions?

2 Sep 23, 2011 18:47

Create a separate file e.g. /home/blogs/_my_file.php with your PHP, then edit /skins/yourskin/_item_block.inc.php so load content from this file if post shortname/slug matches "my-games-page"


if( $Item->urltitle == 'my-games-page' )
{	// Load contents form external file
	include '/home/blogs/_my_file.php';
}
else
{
	// ---------------------- POST CONTENT INCLUDED HERE ----------------------
	skin_include( '_item_content.inc.php', $params );
	// Note: You can customize the default item feedback by copying the generic
	// /skins/_item_content.inc.php file into the current skin folder.
	// -------------------------- END OF POST CONTENT -------------------------
}

Now you need to create a new "page" with url name "my-games-page" in your blog. And it will show your custom games page.

ps if you want to make multiple pages do this


if( file_exists('/home/blogs/my_pages/'.$Item->urltitle.'.php') )
{    // Load custom page if it's found
    include '/home/blogs/my_pages/'.$Item->urltitle.'.php';
}
else
{
    skin_include( '_item_content.inc.php', $params );
}

4 Sep 23, 2011 21:47

I can't really help without knowing your "SQL part" :)
If your games script pulls info from the same tadabase where b2evo is installed, the should be no problems. However you may need to rewrite that file to make it work inside your blog.

Basically you don't need to create new mysql connection, and send headers.
Can you PM me the file?

5 Sep 23, 2011 22:45

This is the code with the connection removed. I could add them to the b2 database, that's just not how I had it originally.


<h2>Games</h2>

<? php
$query  = "SELECT * from games ORDER BY name ASC";
$result = mysql_query($query);


while($game = mysql_fetch_array($result, MYSQL_ASSOC))

{
echo "<div class=image_block style=\"width: 160px; float: left;\">";
echo "<a href=\"../../games/".$game['link'].".html\" onclick=\"NewWindow\(this.href,\'name\',\'".$game['width']."\',\'".$game['height']."\',\'yes\'\);return false;\"><img src=\"../../games/gamethumbs/".$game['link'].".jpg\" /></a><br />";
echo "<a href=\"../../games/".$game['link'].".html\" onclick=\"NewWindow\(this.href,\'name\',\'".$game['width']."\',\'".$game['height']."\',\'yes\'\);return false;\">".$game['name']."</a><br />";
echo "<div style=\"text-align:left;\">".$game['about']."</div></div>";

   }

?>

Just navigating to the page itself makes it work. I'm unable to make it work when pulled into b2evo.

6 Sep 23, 2011 23:58

Try this

<h2>Games</h2>

<?php
global $DB;

$SQL = "SELECT * from games ORDER BY name ASC";
if( $games = $DB->get_results( $SQL, ARRAY_A ) )
{
	foreach( $games as $game )
	{
		echo "<div class=image_block style=\"width: 160px; float: left;\">";
		echo "<a href=\"../../games/".$game['link'].".html\" onclick=\"NewWindow\(this.href,\'name\',\'".$game['width']."\',\'".$game['height']."\',\'yes\'\);return false;\"><img src=\"../../games/gamethumbs/".$game['link'].".jpg\" /></a><br />";
		echo "<a href=\"../../games/".$game['link'].".html\" onclick=\"NewWindow\(this.href,\'name\',\'".$game['width']."\',\'".$game['height']."\',\'yes\'\);return false;\">".$game['name']."</a><br />";
		echo "<div style=\"text-align:left;\">".$game['about']."</div></div>";
   }
}

?>

Also I don't think this code is executed in the first place. See if this works first

if( $Item->urltitle == 'my-games-page' )
{    // See if you can at least display something simple
    echo 'Hello World!';
}
else
{
    // ---------------------- POST CONTENT INCLUDED HERE ----------------------
    skin_include( '_item_content.inc.php', $params );
    // Note: You can customize the default item feedback by copying the generic
    // /skins/_item_content.inc.php file into the current skin folder.
    // -------------------------- END OF POST CONTENT -------------------------
} 

By the way, you need to copy or move the "games" table into b2evolution database.

7 Sep 24, 2011 02:54

Ok, tried the second one and yeah, it's not activating it. Maybe I'm missing something because I had to create it from another skin's item_block as there wasn't one in my base skins folder?

8 Sep 24, 2011 04:16

Then your skin probably not using that file. You don't have to place the code strictly in _item_block.inc.php

Just find this string in either index.main.php or page.main.php

skin_include( '_item_content.inc.php', $params ); 

and wrap it with if{} like I posted before

9 Sep 24, 2011 15:11

That's actually on the page.main.php:


<?php
					// ---------------------- POST CONTENT INCLUDED HERE ----------------------
					skin_include( '_item_content.inc.php' );
					// Note: You can customize the default item feedback by copying the generic
					// /skins/_item_feedback.inc.php file into the current skin folder.
					// -------------------------- END OF POST CONTENT -------------------------
					?>

Do you want me to send you the code for each of those pages?

11 Sep 25, 2011 16:11

I did, it's still not doing it.

page.main.php:


<?php
/**
 * This is the main/default page template for the "custom" skin.
 *
 * This skin only uses one single template which includes most of its features.
 * It will also rely on default includes for specific dispays (like the comment form).
 *
 * For a quick explanation of b2evo 2.0 skins, please start here:
 * {@link http://manual.b2evolution.net/Skins_2.0}
 *
 * The main page template is used to display the blog when no specific page template is available
 * to handle the request (based on $disp).
 *
 *
 * @version $Id: index.main.php,v 1.1 2008/04/15 17:52:15 fplanque Exp $
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

if( version_compare( $app_version, '2.4.1' ) < 0 )
{
	die( 'This skin is designed for b2evolution 2.4.1 and above. Please <a href="http://b2evolution.net/downloads/index.html">upgrade your b2evolution</a>.' );
}

// This is the main template; it may be used to display very different things.
// Do inits depending on current $disp:
skin_init( $disp );


// -------------------------- HTML HEADER INCLUDED HERE --------------------------
skin_include( '_html_header.inc.php' );
// Note: You can customize the default HTML header by copying the generic
// /skins/_html_header.inc.php file into the current skin folder.
// -------------------------------- END OF HEADER --------------------------------
?>

<div class="colmask blogstyle">
  <div class="colmid">
   <div class="colleft">
    <div class="col1wrap">
     <div class="col1">
	<!-- Column 1 start -->

		<div id="header">

			<div id="title">
				<?php
				// ------------------------- "Header" CONTAINER EMBEDDED HERE --------------------------
				// Display container and contents:
				skin_container( NT_('Header'), array(
				// The following params will be used as defaults for widgets included in this container:
				'block_start'       => '<div class="quote">',
				'block_end'         => '</div>',
				'block_title_start' => '',
				'block_title_end'   => '',
				) );
				// ----------------------------- END OF "Header" CONTAINER -----------------------------
				?>
			</div>
		</div>
		

		<div class="post">


			<?php
			// ------------------------- MESSAGES GENERATED FROM ACTIONS -------------------------
			messages( array(
			'block_start' => '<div class="action_messages">',
			'block_end'   => '</div>',
			) );
			// --------------------------------- END OF MESSAGES ---------------------------------
			?>


			<?php	// ---------------------------------- START OF POSTS --------------------------------------
			// Display message if no post:
			display_if_empty();
			while( $Item = & mainlist_get_item() )
			{	// For each blog post, do everything below up to the closing curly brace "}"
			?>

				<div id="<?php $Item->anchor_id() ?>" lang="<?php $Item->lang() ?>">
				<?php
				$Item->locale_temp_switch(); // Temporarily switch to post locale (useful for multilingual blogs)
				?>
	
					<div class="pages">
					<h1>
	        			<a href="<?php $Item->permanent_url() ?>" title="<?php echo T_('Permanent link to full entry') ?>"></a>
						<?php $Item->title(); ?>
					</h1>
					<?php

					if( $Item->urlname == 'my-games-page' )
					{    // See if you can at least display something simple
					    echo 'Hello World!';
					}
					else
					{
					    // ---------------------- POST CONTENT INCLUDED HERE ----------------------
					    skin_include( '_item_content.inc.php', $params );
					    // Note: You can customize the default item feedback by copying the generic
					    // /skins/_item_content.inc.php file into the current skin folder.
					    // -------------------------- END OF POST CONTENT -------------------------
					} 

					?>
			
				 	</div>
				</div>
	
			<?php
				locale_restore_previous();	// Restore previous locale (Blog locale)
			?>
			<?php } // --------------------------------- END OF POSTS ----------------------------------- ?>

			<?php
			// -------------- MAIN CONTENT TEMPLATE INCLUDED HERE (Based on $disp) --------------
			skin_include( '$disp$', array(
					'disp_posts'  => '',		// We already handled this case above
					'disp_single' => '',		// We already handled this case above
					'disp_page'   => '',		// We already handled this case above
				) );
			// Note: you can customize any of the sub templates included here by
			// copying the matching php file into your skin directory.
			// ------------------------- END OF MAIN CONTENT TEMPLATE ---------------------------
			?>


				<div align="center">
				<?php
				// -------------------- PREV/NEXT PAGE LINKS (POST LIST MODE) --------------------
				mainlist_page_links( array(
				'block_start' => '<p class="center">',
				'block_end' => '</p>',
				'links_format' => '$prev$ :: $next$',
				'prev_text' => '&lt;&lt; '.T_('Previous'),
				'next_text' => T_('Next').' &gt;&gt;',
				) );
				// ------------------------- END OF PREV/NEXT PAGE LINKS -------------------------
				?>
				</div>

		</div>


<!-- Column 1 end -->

    </div>
   </div>

    <div class="col2">
	<!-- Column 2 start -->

		<div id="fixed">
			<img src="images/title.png">
			<P>
			<center>
			<a href=http://www.chronomorphosis.com/azha/ target="new"><img border=0 src=http://dubird.net/banners/dubirdkitty.gif class=img></a>
			<br>
			<a href=http://s85.photobucket.com/albums/k48/dubird/kitty/ target="new"><img border=0 src=http://dubird.net/banners/amisikitty.gif class=img></a>
			</center>
		</div>

	<!-- Column 2 end -->
    </div>

    <div class="col3">
	<!-- Column 3 start -->

		<div id="icons">
		<a href="index.php?tempskin=_rss2" onmouseover="movepic('rss','images/rss_icon_on.gif')" onmouseout="movepic('rss','images/rss_icon.gif')"><img src="images/rss_icon.gif" alt="RSS Feed" border="0" target="new" name="rss"></a>&nbsp;
		<a href="http://www.twitter.com/dubird" onmouseover="movepic('twitter','images/twitter_icon_on.gif')" onmouseout="movepic('twitter','images/twitter_icon.gif')"><img src="images/twitter_icon.gif" alt="Twitter" border="0" target="new" name="twitter"></a>&nbsp;
		<a href="http://www.facebook.com/dubirdrs" onmouseover="movepic('fb','images/facebook_icon_on.gif')" onmouseout="movepic('fb','images/facebook_icon.gif')"><img src="images/facebook_icon.gif" alt="Facebook" border="0" target="new" name="fb"></a>&nbsp;
		<a href="http://dubird.deviantart.com" onmouseover="movepic('devart','images/devart_icon_on.gif')" onmouseout="movepic('devart','images/devart_icon.gif')"><img src="images/devart_icon.gif" alt="devart" border="0" target="new" name="devart"></a>&nbsp;
		</div>

	<P>

		<div id="pagenav">
		<ul>
		<?php
			// ------------------------- "Menu" CONTAINER EMBEDDED HERE --------------------------
			// Display container and contents:
			// Note: this container is designed to be a single <ul> list
			skin_container( NT_('Menu'), array(
			// The following params will be used as defaults for widgets included in this container:
			'block_start'         => '',
			'block_end'           => '',
			'block_display_title' => false,
			'list_start'          => '',
			'list_end'            => '',
			'item_start'          => '<li>',
			'item_end'            => '</li>',
			) );
			// ----------------------------- END OF "Menu" CONTAINER -----------------------------
			?>
		</ul>
		</div>

	<?php
		// ------------------------- SIDEBAR INCLUDED HERE --------------------------
		skin_include( '_sidebar.inc.php' );
		// Note: You can customize the default BODY footer by copying the
		// _body_footer.inc.php file into the current skin folder.
		// ----------------------------- END OF SIDEBAR -----------------------------
	?>

	<!-- Column 3 end -->

    </div>

   </div>
  </div>
</div>


<?php
// ------------------------- BODY FOOTER INCLUDED HERE --------------------------
skin_include( '_body_footer.inc.php' );
// Note: You can customize the default BODY footer by copying the
// _body_footer.inc.php file into the current skin folder.
// ------------------------------- END OF FOOTER --------------------------------
?>




</body>
</html>

14 Sep 25, 2011 20:14

My mistake, it should be $Item->urltitle instead

15 Sep 26, 2011 02:06

Ok, that works! When I tried the include, I had to put it in the skins folder, but at least it works now. I don't know why /home/games.php didn't work though, since the install is in the base directory.

16 Sep 26, 2011 03:10

Instead of skin_include() you ca simply use

include '/absolute/path/to/file.php';


Form is loading...