Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Using both Default and Portfolio layout in Autofocus+ Pro WordPress

  • REFUNDED

Hi there,

I'm trying to set up a photo portfolio site using the Autofocus+ Pro template.
In this template there's an option to change the default AutoFocus style homepage to a portfolio style. The default and portfolio looks are both stored in a .css, not in a Page Template file.
I'd like to create 2 different pages. One is a photo blog with the Default layout, the other is a Portfolio page with the Portfolio layout. And best of all, both these pages won't be the homepage.

Should I maybe create 2 page template files, containing both layout? And if so, how do I do that? Or is there another solution for this? Help would be wonderful!

-see the AutoFocus theme on http://fthrwght.com/autofocus

Answers (1)

2010-10-14

Baki Goxhaj answers:

You should create to different templates with each the needed code.

Can I have a look at your actual home.php (or index.php if you don't have a home)? I don't have the pro version.


Tim Hoeben comments:

Sure thing!
The AutoFocus+ Pro template doesn't have an index.php file though. There's only 2 extra files in the main theme folder, editor-style.css and blog-template.php (a template file with yet another layout)
But the whole test site is at http://timhoeben.nl/marjan/
Then there's the css files containing the 2 layouts at

http://timhoeben.nl/marjan/wp-content/themes/autofocuspro/css/default-layout.css
http://timhoeben.nl/marjan/wp-content/themes/autofocuspro/css/portfolio-layout.css

Is that any help? For further reference maybe the Free version on http://fthrwght.com/autofocus/, which is almost the same.






Baki Goxhaj comments:

I have the free version already. And yes, it does not have many files since it's a child theme. What I need now is to have a look at the piece of functions that shows the makes the style appear.

All we have to do is make a if loop there.

Can you have a look at functions.php also at style.css.


Tim Hoeben comments:

Looks like this is it in function.php:

// Add custom Plugins and Styles on NON-admin pages.
function af_enqueue_styles() {
global $afoptions;
foreach ($afoptions as $value) {
if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}

if ( !is_admin() ) { // Is this necessary?

if ($af_sliding_sticky_area == 'true' && $af_portfolio_layout == 'false' ) {
wp_enqueue_style('afdefaultslider', get_bloginfo('stylesheet_directory') . '/css/default-slider-layout.css','','20100629','all');
} elseif ( $af_portfolio_layout == 'false' ) {
wp_enqueue_style('afdefault', get_bloginfo('stylesheet_directory') . '/css/default-layout.css','','20100329','all');
} elseif ( $af_portfolio_layout == 'true' ) {
wp_enqueue_style('afportfolio', get_bloginfo('stylesheet_directory') . '/css/portfolio-layout.css','','20100610','all');
}

// BOO IE6! :-/
wp_enqueue_style('afiestyles', get_bloginfo('stylesheet_directory') . '/css/ie-styles.css','','20100329','all');

}
}
add_action('init', 'af_enqueue_styles');


Then there's also the Admin Option to switch between the two:
array( "name" => __('Portfolio Layout','thematic'),
"desc" => __('Switch to the Portfolio layout on the home page?','thematic'),
"id" => $afshortname."_portfolio_layout",
"std" => "false",
"type" => "checkbox"),


There isn't any reference to the portfolio in style.css


Baki Goxhaj comments:

What I added is in blod - here it goes:




<a class="preview" href="<?php the_permalink() ?>" title="<?php the_title(); ?>">

<?php $urlHome = get_bloginfo('template_url'); ?>

<?php $th_url = (get_post_meta($post->ID, "post_image_value", $single = true)) ? $urlHome . "/scripts/timthumb.php?src=".get_post_meta($post->ID, "post_image_value", $single = true)."&amp;w=".get_option('cb_featured_posts_width')."&amp;h=".get_option('cb_featured_posts_height')."&amp;zc=1" : $urlHome ."/images/th_80x80.jpg"; ?>

<img alt="<?php the_title(); ?>" src="<?php echo $th_url; ?>" width="<?php echo get_option('cb_featured_posts_width'); ?>" height="<?php echo get_option('cb_featured_posts_height'); ?>" />

<?php
// Add custom Plugins and Styles on NON-admin pages.

function af_enqueue_styles() {

global $afoptions;

foreach ($afoptions as $value) {

if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }

}



if ( !is_admin() ) { // Is this necessary?

if ($af_sliding_sticky_area == 'true' && $af_portfolio_layout == 'false' ) {

wp_enqueue_style('afdefaultslider', get_bloginfo('stylesheet_directory') . '/css/default-slider-layout.css','','20100629','all');

} elseif ( $af_portfolio_layout == 'false' ) {

wp_enqueue_style('afdefault', get_bloginfo('stylesheet_directory') . '/css/default-layout.css','','20100329','all');

} elseif ( $af_portfolio_layout == 'true' ) {

wp_enqueue_style('afportfolio', get_bloginfo('stylesheet_directory') . '/css/portfolio-layout.css','','20100610','all');

}

<strong> if( is_page_template('my_template.php') ) {

wp_enqueue_style('afdefault', get_bloginfo('stylesheet_directory') . '/css/default-layout.css','','20100329','all');

}

if( is_page_template('other_template.php') ) {

wp_enqueue_style('afportfolio', get_bloginfo('stylesheet_directory') . '/css/portfolio-layout.css','','20100610','all');

}</strong>

// BOO IE6! :-/

wp_enqueue_style('afiestyles', get_bloginfo('stylesheet_directory') . '/css/ie-styles.css','','20100329','all');



}

}

add_action('init', 'af_enqueue_styles');


Replace my_template.php and other_template.php with your real template names.


Tim Hoeben comments:

That actually gives me an unexpected } error on line 864, which is the last } in your added piece of code. See http://www.timhoeben.nl/marjan


Baki Goxhaj comments:

You need to change the position of bold part of the script one } below.


Tim Hoeben comments:

Alright now I have this piece of code:
// Add custom Plugins and Styles on NON-admin pages.
function af_enqueue_styles() {
global $afoptions;
foreach ($afoptions as $value) {
if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}

if ( !is_admin() ) { // Is this necessary?

if ($af_sliding_sticky_area == 'true' && $af_portfolio_layout == 'false' ) {
wp_enqueue_style('afdefaultslider', get_bloginfo('stylesheet_directory') . '/css/default-slider-layout.css','','20100629','all');
} elseif ( $af_portfolio_layout == 'false' ) {
wp_enqueue_style('afdefault', get_bloginfo('stylesheet_directory') . '/css/default-layout.css','','20100329','all');
} elseif ( $af_portfolio_layout == 'true' ) {
wp_enqueue_style('afportfolio', get_bloginfo('stylesheet_directory') . '/css/portfolio-layout.css','','20100610','all');
}

// BOO IE6! :-/
wp_enqueue_style('afiestyles', get_bloginfo('stylesheet_directory') . '/css/ie-styles.css','','20100329','all');

}

if( is_page_template('default.php') ) {
wp_enqueue_style('afdefault', get_bloginfo('stylesheet_directory') . '/css/default-layout.css','','20100329','all');
}

if( is_page_template('portfolio.php') ) {
wp_enqueue_style('afportfolio', get_bloginfo('stylesheet_directory') . '/css/portfolio-layout.css','','20100610','all')
}

}
add_action('init', 'af_enqueue_styles');


Still there's an unexpected }, now on line 866, which is still the last on of your piece of code.