Welcome, Guest. Please login or register.
February 11, 2012, 06:08:50 AM
48 Posts in 25 Topics by 103 Members
Latest Member: JerricaBeachamp
ModStomp Forum  |  Main Forums  |  Wordpress Tweaks and Tactics  |  Falbum Sidebar & Page Title Issues With K2 Theme « previous next »
Pages: [1]
Author Topic: Falbum Sidebar & Page Title Issues With K2 Theme  (Read 1451 times)
Rudeboy
ModStomp Admin
Administrator
Jr. Member
*****
Posts: 41


Ruder than you!


View Profile WWW
« on: December 19, 2006, 06:53:02 PM »

Ok, so these issues were mostly my fault because I didn't read the K2 integration instructions HERE.  In my defense though, the instructions are pretty sparse and it was only after a couple days of digging that I even figured out that the issues I was having were being caused by this.  The problem is that Falbum worked with K2 pretty much out of the gate so I didn't really notice the sidebar and page title issues for a little while.  Anyway, in addition to the instructions on Randombyte, here are a few words of wisdom to help your install go smoothly.

Once you have falbum uploaded and activated to your Wordpress installation, you will need to get your falbum page template set up.  This is the part that I failed to do because falbum will actually work without this template file, plus the fact that this step isn't included in the default installation instructions.  Falbum will work on K2 without this file, it just won't work correctly.  To get this page set up, create a new file and call it falbum.php.  Then paste the following code into this page and save and post it to your K2 root folder.

Code:
<?php
/*
   Template Name: FAlbum Page template
*/
 
//Hack to set WP page id
$page_id null//Change this to match your sites WP page id of new Photos page
 
global $wp_query;
global 
$post;
if (
$page_id != null) {
  
$post->ID $page_id;
  
$wp_query->is_home false;
  
$wp_query->is_page true;
  
$wp_query->queried_object->ID $page_id;
  
$wp_query->queried_object_id $page_id;
}
 
get_header();
?>

 
<script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/jquery.js"></script>
<script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/falbum.js"></script>
<script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/overlib.js"></script>
<?php if ($falbum->can_edit) { ?><script type="text/javascript" src="<?php echo get_settings('siteurl'); ?>/wp-content/plugins/falbum/res/prototype.js"></script><?php ?>
 
<?php /* Remove or comment out the below line after to finding the Photos page page_id */
if ($page_id == null) { echo '<h2>page_id = '.$post->ID.'</h2>'; }
?>

 
<div class="content">
   <div id="primary">
      <div id="current-content">
         <div>
            <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
            <?php $falbum->show_photos(); ?>
         </div>
      </div>
      <div id="dynamic-content"></div>
   </div>
   <?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>

One thing to note here is that there is actually a file named falbum.php in your falbum root folder as well.  Do not get these files mixed up or else Wordpress will start throwing all sorts of errors.  Do not decide to name this file something else though.  It is imperative that you name this file falbum.php.  DO NOT DEVIATE FROM THIS!  Because I had integrated Falbum on my own a few weeks earlier, I had already created a template file called falbum.php so when I followed the Randombyte instructions I decided to name the new template different from what the instructions said.  Big mistake.  The reason you want to name this file appropriately is that the falbum code looks for this template file specifically in order to format the album and photo pages.  The tricky thing is, the album and photo pages will actually display correctly without this template file.  However, the page_id code snippets in this template are vital to having the sidebar and page titles work correctly. 

Once you have this file created and posted, you will next need to modify the header.php file located in your K2 root folder.  You will need to post the following bit of code into the head portion of that file:

Code:
<!-- Start FAlbum Title -->
<?php
require_once(ABSPATH.'/wp-content/plugins/falbum/falbum.php');
global 
$falbum;
?>

<?php global $falbum;?>
<?php if ($falbum->is_album_page()) { ?>
  <title><?php echo $falbum->get_page_title(); ?></title>
<?php } else { ?>
  <title><?php wp_title(''); if (function_exists('is_tag') and is_tag()) { ?>Tag Archive for <?php echo $tag; } if (is_archive()) { ?> archive<?php } elseif (is_search()) { ?> Search for <?php echo $s; } if ( !(is_404()) and (is_search()) or (is_single()) or (is_page()) or (function_exists('is_tag') and is_tag()) or (is_archive()) ) { ?> at <?php ?><?php bloginfo('name'); ?></title>
<?php ?>
<!-- End FAlbum Title -->

This was the second place that I screwed up.  The instructions on Randombyte simply state to paste this code into the header.php file.  What they fail to mention is that the location of this code is VERY important if you want the titles of your falbum album and photo pages to display correctly.  If you do not position this code correctly then both your album and photo pages will grab the title of the most recent blog post on your home page.  I'm not exactly sure why this is, but by placing this code directly after the this line:

Code:
<head profile="http://gmpg.org/xfn/11">

and directly before this line:

Code:
<title><?php wp_title(''); if (function_exists('is_tag') and is_tag()) { ?>Tag Archive for <?php echo $tag; } if (is_archive()) { ?> archive<?php } elseif (is_search()) { ?> Search for <?php echo $s; } if ( !(is_404()) and (is_search()) or (is_single()) or (is_page()) or (function_exists('is_tag') and is_tag()) or (is_archive()) ) { ?> at <?php ?> <?php bloginfo('name'); ?></title>

the page title issues will not occur.

Now, the main purpose of these code adjustments is actually not to fix either of the issues I have mentioned.  This code is actually designed to make the album and photo pages in falbum a child of your main gallery page so that they will inherit the properties of that page and will display under the correct navigation option.  Once you have the code adjustments above in place there is one last thing you will need to do to complete the integration though.  You will need to create a static page for your gallery.  The instructions for this are included in the installation readme for falbum so I won't go into detail about how to do it.  One thing I will mention though as that when you create this static page, select the "FAlbum page template" template that should now be available.  Once you have that page created, go to the page management screen and grab the page ID of your new gallery page.  You will need to stick that ID into the falbum.php template page that you just created.  The instructions on Randombyte for this portion of the process are sufficient so I won't post the complete process, but as long as you name your file correctly and position your code snippet into the header.php file correctly, you shouldn't have any sidebar/page title issues with your FAlbum installation.  If these instructions don't work, let me know and I'll dig into it a bit further to make sure I didn't omit something.
Logged

AMD Athlon 64 3000+ (oc'ed to 1.94 GHz)
1 GB of DDR 3200
MSI Nvidia GeForce 6800 (oc'ed to 400 MHz)
Aspire X-Dreamer II case (slightly modded)
Pages: [1]
« previous next »
    Jump to:  


    Once You Know, You Newegg