Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Montezuma Theme (http://forum.bytesforall.com/forumdisplay.php?f=53)
-   -   adding physical templates (http://forum.bytesforall.com/showthread.php?t=19099)

jeffe Dec 11, 2012 01:47 PM

adding physical templates
 
Howdy
I would like to create, with full php power, a template to use for my homepage.
This is so I can use some 'do_shortcode' calls required by other plugins.

What am I missing - there is no spot on my page editor to choose a non-virtual theme.

I have uploaded my theme into the main montezuma theme folder.

I even tried naming it 'front-page.php', but this would not render any headers. I would also just like to know how to use my own templates.

Thank you.
-j

lmilesw Dec 11, 2012 02:24 PM

I am not clear on how you installed Montezuma. You should just install like any other theme. Then within the theme options you create the virtual templates.

juggledad Dec 11, 2012 03:35 PM

If you want to create page templates outside the theme options, copy index.php as your base. It will not be editable via the theme options, but you can use dashboard->appearances->editor to edit it.

jeffe Dec 12, 2012 01:03 PM

Thanks for the replies...
Quote:

Then within the theme options you create the virtual templates.
I don't want to use virtual templates - I want to create physical templates so I can use all the usual php functions and specifically some 'shortcode' from other plugins.

Quote:

If you want to create page templates outside the theme options, copy index.php as your base. It will not be editable via the theme options, but you can use dashboard->appearances->editor to edit it.
I tried that - but there is no place in the page editor to choose a non-virtual template.

Here is a clear example...
I want to create a full php template (not a virtual template) called 'mytemplate.php'. I want to apply this to a page I create called 'My Page'.
I can definitely start by copying index.php - but then how do I use that template for 'My page'?

Part of Montezuma's ad says 'The ability to create physical page templates is preserved.'... how do I still use these 'physical' page templates if there is no way to assign them via the page editor? I only see option to use virtual templates.

juggledad Dec 12, 2012 01:08 PM

Quote:

how do I still use these 'physical' page templates
the same as you would fro any theme. When you create a page look in the right hand colum for the section 'Templates' that is where you pick your template.

jeffe Dec 12, 2012 01:13 PM

Thats what I thought - but I only have boxes labelled:
Publish - Page Attributes - Virtual Templates - Featured Image
http://i45.tinypic.com/14mb7sw.png

I have also checked 'Screen Options' but found nothing that seems to help.
Thanks yall

edit: also using latest version of wordpress (3.5) but experienced the same behavior on 3.4.2

lmilesw Dec 12, 2012 01:30 PM

You, of course, do have to add code to the top of your template to let WordPress know it is a template. For example
PHP Code:

<?php
/*
Template Name: My Template
*/
?>


jeffe Dec 12, 2012 01:37 PM

Thank you, that did the trick.

I thought there was something like that but could not find an example in the montezuma theme.

Thank you again...
-j

jeffe Dec 12, 2012 01:44 PM

Of course this opens up a new myriad of issues as get_header.php doesn't really do what I want.
I'm assuming this is because the default Montezuma header has Montezuma-specifc code in it.

A suggestion would be to include an example for a physical template so we could work off of that.

THank yall

lmilesw Dec 12, 2012 01:47 PM

That info is in the WordPress Codex.

jeffe Dec 12, 2012 02:21 PM

edit: the info in this post only gets you halfway...
Thanks
For anyone else, the issue was partly because 'get_header()' referenced the montezuma 'header.php' which only had code to reference the montezuma virtual subtemplate 'header'.

I created a new file, 'header-template.php' and referenced that in my physical template with get_header('template').
Then, I copy/pasted all the data from head.php, and added on the contents of the virtual 'header.php' sub-template.
Then, I copy/pasted all the lines AFTER the get_header call in the contents of the 'index.php' VIRTUAL template, into my new physical template.

Adding a basic loop in there, and we are good to go.

Thanks for your help again.
-j

jeffe Dec 12, 2012 03:29 PM

Bump - this is not working out as easily as it looked.

There is still 'some' missing data from my template which I'm not sure how to get at.

For example, some of my plugins became disabled, and the wordpress menu (when you are logged in) that normally overlays the page at the top is gone as well.

Any ideas how to get a generic 'physical' template working?

thank yall
-j

jeffe Dec 12, 2012 03:58 PM

OK - think I got it.

Here are the files I used to create a new generic physical template that works with montezuma:
header-template.php:
Code:

<?php get_template_part( 'head' ); ?>
</head>
<body <?php body_class(); ?>>
        <div id="banner-bg" class="cf">
        <div id="banner" class="row">
                <div id="logo-area" class="col5">
                        <<?php bfa_if_front_else( 'h1', 'h3' ); ?> id="sitetitle">
                                <a href="<?php echo home_url(); ?>"><?php bloginfo( 'name' ); ?></a>
                        </<?php bfa_if_front_else( 'h1', 'h3' ); ?>>
                        <p id="tagline"><?php bloginfo( 'description' ); ?></p>
                </div>
        <?php wp_nav_menu( array(
                        'container' => 'nav',
                        'container_class' => 'menu-wrapper col7',
                        'container_id' => 'menu1-wrapper',
                        'menu_id' => 'menu1',
                        'menu_class' => 'cf menu',
                        'theme_location' => 'menu1',
                        'fallback_cb' => 'bfa_page_menu'
                ) ); ?>
                </div><!-- banner -->
        </div><!-- banner-bg -->
        <a href="<?php bloginfo( 'rss2_url' ); ?>" class="rsslink" title="<?php _e( 'Subscribe to RSS Feed', 'montezuma' ); ?>"></a>

new-template.php:
Code:

<?php
/*
Template Name: New Template
*/
get_header('template');
?>
        <div id="main" class="row">
                <div id="content" class="cf col8">
                <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                        <?php the_content();?>
                <?php endwhile; else: ?>
                <p>Sorry, no posts matched your criteria.</p>
                <?php endif; ?>
                </div>               
                <div id="widgetarea-one" class="col4">
                        <?php dynamic_sidebar( 'Widget Area ONE' ); ?>
                </div>       
        </div><!-- main -->
        <?php wp_footer(); ?>
        <?php get_footer('template'); ?>

footer-template.php:
Code:

</body>

</html>


Michael4fm Jan 8, 2013 09:28 AM

Thanks for posting this, Jeffe :)

I've been struggling with 'custom' physical templates too, and using your code I think I'm now moving in the right direction.

For anyone else who comes looking: I got a slight 'lining up' problem with the physical header not quite matching my 'virtual' ones. Seem to have solved this by copying and repasting the text from the virtual template file 'header.php'. [Jeffe's example doesn't include the 'breadcrumbs' div] I also couldn't get it to display comment and footer templates ... but seem to have resolved this by using get_footer() instead of get_footer('template') in new-template.php

Have to agree with Jeffe ... life would have been far simpler if there was a 'sample' physical template to re-engineer from! But it's such a great looking - and generally working - theme that I really hope I crack any problems instead of giving up! ;)

If you want to see how it's going - in case I've worked out how to do something you're trying to - check out http://www.other.s-t-u-f-f.net and http://www.play.s-t-u-f-f.net ... the former is a 'real' site (which I'm developing first using Wampserver offline) and the latter is a 'test' site to check things work on my real server as they did on the Wampserver!

jerryc Jan 8, 2013 02:36 PM

Quote:

Originally Posted by Michael4fm (Post 94652)
Have to agree with Jeffe ... life would have been far simpler if there was a 'sample' physical template to re-engineer from!

It's quite simple to reengineer from the virtual templates. From the dashboard > appearance > montezuma options > main templates, when you create a new template, there's an option to copy an existing one. Try starting there, and things might be easier, particularly with having things line up.

Michael4fm Jan 8, 2013 02:46 PM

Tried that ... most copied templates seem to be coming up 'blank' for some reason ... and I'm fairly sure that when I have copied the contents of a 'virtual' template to ".../wp-content/themes/montezuma" although the re-engineered page / post etc. is there, there's no styling / header / footer etc. Jeffe's way may not be the 'right' way ... but it's working ;)

jerryc Jan 8, 2013 03:55 PM

Quote:

Originally Posted by Michael4fm (Post 94672)
Tried that ... most copied templates seem to be coming up 'blank' for some reason

I never had that problem, but I'm only using wp for pages right now, not posts.

When you say blank, do you mean the template file in the online editor is blank or the page /post where you use the template is coming up blank?

Michael4fm Jan 8, 2013 04:24 PM

Quote:

Originally Posted by jerryc (Post 94674)
When you say blank, do you mean the template file in the online editor is blank or the page /post where you use the template is coming up blank?

The template file is blank ... think when I accidentally reload some of the templates I'm trying to copy (I'm left handed, and the 'save' and the 'reload original template' buttons are dangerously close together!) they're blank too ... but I've been playing around so much trying to get a physical template that may be my own fault.

I need to use 'non-standard' php and 'if' conditions in posts ... and once I've cracked that (which I seem to have!) then I need to use what I learn on 'index.php' and all of the other WP templates that are similar ... 'category.php', 'tag.php', 'search.php', etc. (Hey, maybe I'll even work out how to get two columns of excerpts. That was my original start point anyway ... led me to this theme, now it's taking days and days! :( )

jerryc Jan 8, 2013 05:00 PM

Quote:

Originally Posted by Michael4fm (Post 94678)
The template file is blank ... think when I accidentally reload some of the templates I'm trying to copy (I'm left handed, and the 'save' and the 'reload original template' buttons are dangerously close together!) they're blank too ... but I've been playing around so much trying to get a physical template that may be my own fault.

Create them via the dashboard editor, not ftp. Stuff you ftp doesn't usually show up right, at least that's my experience, and what I remember juggledad saying. Ever since I did that, I haven't had a problem.

Also, any template can be restored to it's defaults. On the edit page, there's a reset button. Maybe you can try that with an obscure one, and see what happens.

Quote:

I need to use 'non-standard' php and 'if' conditions in posts ... and once I've cracked that (which I seem to have!) then I need to use what I learn on 'index.php' and all of the other WP templates that are similar ... 'category.php', 'tag.php', 'search.php', etc. (Hey, maybe I'll even work out how to get two columns of excerpts. That was my original start point anyway ... led me to this theme, now it's taking days and days! :( )
Ok, I'll preface this part for the newbies who don't know any php to ignore this, as it may be over their head.

Even though I don't know much about posts or excerpts, I do understand php arrays. I have an example of one posted here that might be helpful as a starting point. Here's the sequence of what I'm doing:
  1. make an array of my images
  2. order them the way I want (in my case, random)
  3. put the first 6 in row 1
  4. put the next 6 in row 2

Modified to what it sounds like you're doing:
  1. make an array of your excerpts
  2. order them the way you want (probably descending date order)
  3. put the first n in column 1
  4. put the next n in column 2

If, instead, you wanted them laid out:
1 | 2
3 | 4
5 | 6
...

or a different group of excerpts in each column, you'd just modify the code accordingly, which it sounds like you can figure out.

I hope this helps.

Michael4fm Jan 8, 2013 05:45 PM

Quote:

Originally Posted by jerryc (Post 94680)
Create them via the dashboard editor, not ftp. Stuff you ftp doesn't usually show up right, at least that's my experience, and what I remember juggledad saying. Ever since I did that, I haven't had a problem.

Never had a problem with FTP, and I've just set up a 'wampserver', so it's easier for me to play directly then FTP once a file works as I want it.

Quote:

Originally Posted by jerryc (Post 94680)
Also, any template can be restored to it's defaults. On the edit page, there's a reset button. Maybe you can try that with an obscure one, and see what happens.

If the defaults that are coming up blank. The 'reset' button you mention is the same one as I called 'dangerous'. :) [If anyone who has the ear of the developer is reading this, a simple "Confirm you really want to do that" button would be very very useful for reckless people like me]

...

Thanks for the link and the suggestions. It sounds a bit complicated for me ... the excerpts will be generated by the visitor, using the "Query Multiple Taxonomy" plugin and working out how to turn that into an array ... :confused: (which I'm not yet at all familiar with anyway tbh); but I only need one image for each excerpt on the site I'm currently working on, so there could be a lot of 'white' space.

Now I've sussed out physical templates I think I'll be able to 'hack' the POSTS loop to get a 1-3-5 column and a 2-4-6 one. I'm leaving that till 'last' though ... I suspect I'll be saying goodbye to a large chunk of my life to get that working!

jerryc Jan 8, 2013 09:14 PM

Quote:

Originally Posted by Michael4fm (Post 94683)
Never had a problem with FTP, and I've just set up a 'wampserver', so it's easier for me to play directly then FTP once a file works as I want it.

The problem isn't with FTP. As I understand it, making a template any other way other than the dashboard editor is, to my understanding, not recommended.

Quote:

If the defaults that are coming up blank. The 'reset' button you mention is the same one as I called 'dangerous'. :) [If anyone who has the ear of the developer is reading this, a simple "Confirm you really want to do that" button would be very very useful for reckless people like me]
If you're using the editor and the resets are coming up blank, that may be because you overwrote the original files via some other method. You may want to get original files somewhere. Jug probably knows much more about this.

Michael4fm Jan 9, 2013 02:52 AM

Quote:

Originally Posted by jerryc (Post 94680)
If you're using the editor and the resets are coming up blank, that may be because you overwrote the original files via some other method. You may want to get original files somewhere.

You're probably right ... hence my comment that it may have been my own fault! I've got the original files saved somewhere, so if I need to access them I'm sure I'll be able to relatively easily.

juggledad Jan 9, 2013 04:29 AM

Quote:

If the defaults that are coming up blank. The 'reset' button you mention is the same one as I called 'dangerous'. [If anyone who has the ear of the developer is reading this, a simple "Confirm you really want to do that" button would be very very useful for reckless people like me]
good idea.

see RFE 013-07: Add a confirm dialogue to all the 'reset' options

juggledad Jan 9, 2013 04:36 AM

FTP - issues that arise when using FTP depends on how your host is set up and the server UID of teh 'wordpress' user verses the UID of the 'FTP' user. On some hosts, they work together, on some hosts they don't. And that's as far as I'm going to go into it. to give a detailed explaination that a layperson could understand would take a couple hours to think up and write up and edit and since no one is paying me to do it...for a detailed explaination go do a bunch of research on user premissions in apache, wordpress, and ftp. ;)

Michael4fm Jan 9, 2013 04:56 AM

Thanks for the 'short version' explanation, Juggledad. I guess I'm lucky in that FTP has always worked for me with pretty much no problems. I'll continue to use this method, but if it goes belly-up one day, I'll remember your wise words and switch to direct editing via the WP dashboard instead! :)


All times are GMT -6. The time now is 12:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.