WordPress.org

Ready to get started?Download WordPress

Forums

There's More To Life Than INDEX.PHP (11 posts)

  1. createErrorMsg
    Member
    Posted 10 years ago #

    Thanks for the advice. I'm not having a problem, though, with making or modifying templates. Modifying index.php isn't a problem. Creating a brand new template for WP isn't problem. Making WP apply that template to permalinks
    is a problem, because it won't.
    Your idea of making a seperate stylesheet for different "pages", using the same template is interesting, but unfortunately, wont work. My goal is to have each category get it's own template, with it's own static links and permanent content...not doable with CSS alone.

  2. eric
    Member
    Posted 10 years ago #

    I once did something vaguely similar where I had two different templates, both called index.php but in different subdirectories. To get the permalinks and stuff to point back to the same template, I did some simple but horrible hacking in:
    * get_category_link function in wp-includes/template-functions-category.php
    * get_permalink function in wp-includes/template-functions-link.php
    * get_month_link function in wp-includes/template-functions-link.php
    .. in order to make all the URLs relative (i.e. index.php?p=... or ?cat=... instead of http://www.yourdomain.com/index.php?p=...)
    I basically jus replaced
    $file = get_settings('home') . '/' . get_settings('blogfilename');
    with
    $file = get_settings('blogfilename');
    in each function.
    I say horrible because it will make it harder to upgrade to a more recent version of WP, and I don't know whether it would work with fancy URLs using .htaccess rewriting. Oh, and I didn't change the calendar function because I don't use a calendar on that site, but I imagine you could change it the same way.
    Well, it's horrible but it works for me...

  3. maadmob
    Member
    Posted 10 years ago #

    I managed to do something similar to what you want, but with one template for categories and one for individual entries.
    I'm not using .htaccess as I couldn't get it to work. Instead, in the permalink options, I set the first box to:
    /indiv.php/%year%/%monthnum%/%postname%/
    and the second to:
    /catname.php
    This gives me three templates - one for the home page, one for category listings and one for posts.
    Here's the result (available but still a little work on the content):
    http://maadmob.net/maadbooks/

  4. eric
    Member
    Posted 10 years ago #

    Wah this is weird... I guess if I could understand why this works, without .htaccess, I'd finally understand how WP permalinks work. Is all the /cat/year/month/day/post-number/ stuff passed to the template as a query string or something?

  5. createErrorMsg
    Member
    Posted 10 years ago #

    This gives me three templates - one for the home page, one for category listings and one for posts.

    The problem here is that ONLY the homepage uses the original index.php now, any other link is passed through indiv.php. It's a great solution if you just want a new template for individual posts. Unfortunately, I'm looking to make a template for each archive (category). Thanks, though. If all else fails, I'll restructure the IA of the site and use this.

    two different templates, both called index.php but in different subdirectories

    eric, were all the function include files in both folders? In other words, to make your hack work, did you have two folders containing all the WP files, differently hacked with relative URLs?
    You idea seems plausible, and even extendable to use more than just two folders. The difficulty would be getting the category permalink in the first folder's pages to point to the second folder's pages...i.e., how to make the two different templates interact?

  6. eric
    Member
    Posted 10 years ago #

    I use a single installation of WP and each of the files mentioned only exist in the one directory where all the WP stuff resides.
    A simple way to link between cats might be to leave out the "wp_list_cats" tag from your menu, and instead define a link category called "Categories" and add a link (absolute URL) for each category. That way you could manage your cat links from within the WP backend. Of course it wouldn't automatically create/delete/rename the link whenever you create/delete/rename a category. As I said, simple but horrible :)
    I should add that the purpose of my hack is completely different from what you are trying to do: to create a public area and a members area within the same blog (members index.php lives in password-protected directory).

  7. createErrorMsg
    Member
    Posted 10 years ago #

    Really good ideas, eric. I don't plan on changing my categories very often, and even if I do, having to manually change the absolute URLS in two or three files (actually, I could require_once() it in from a text file) is a small price to pay for the flexibility of using different templates. It's certainly better than having to dump WP altogether and write my own CMS.
    Thanks a LOT for the help. I'll give your trick a try this weekend and post back on how it works!

  8. aris
    Member
    Posted 10 years ago #

    The "blogfilename" is stored in database... and one uponce a time (in WP 1.1) it was possible to change this setting from admin pane !!!
    Where is this function now ???
    ;-))

  9. eric
    Member
    Posted 10 years ago #

    eryanv: interesting idea, I'm not sure I really get it though. Would you use .htaccess to make, say, blah.php an alias for index.php, and then define something like:
    $templatename = last part of $_SERVER['REQUEST_URI']
    (everything after the last slash, I guess some PHP string processing function will do this)
    $file = get_settings('home') . '/' . $templatename
    That would be more flexible than my method because you could have template names other than index.php and wouldn't need subdirectories. You would still need to hack functions in wp-includes, though. Am I anywhere near the right track?
    aris: I can't find it either. But that still wouldn't allow more than one template, right?

  10. Kelso
    Member
    Posted 10 years ago #

    Try this. I've found myself in the same situation...
    A 4-step guide to freeing yourself from the single index.php (I'm talking more than one index.php baby!)
    http://wordpress.org/support/3/9752

  11. Anonymous
    Unregistered
    Posted 10 years ago #

    I thought you could use the read more include to point to a seperate file. Such as < ? php the_content("Read full article.","0","blah.php"); ? >

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.