WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] including dynamis info outside of directory (31 posts)

  1. Ryan Fitzer
    Member
    Posted 8 years ago #

    When I create a static page outside of the directory I'm getting errors when trying to include the footer and header. It cannot find the dynamic info (blog name, copyright, etc...) and therefore fails to display the content (template included) correctly. Any thoughts?

  2. moshu
    Member
    Posted 8 years ago #

    You have to add on the top of any file that needs to use WP functions, the following:
    <?php
    require('./path-to/your-blog/wp-blog-header.php');
    ?>

    Right on the top, before everything.

  3. Ryan Fitzer
    Member
    Posted 8 years ago #

    Thanks. I'm still having a problem. Here's the code (without any content stuff so it's easy to read):

    <?php
    require('./wordpress/wp-blog-header.php');
    ?>

    <?php get_header(); ?>

    <!-- content ................................. -->
    <div id="singletop"></div>
    <div id="content">
    </div> <!-- /content -->

    <?php get_footer(); ?>

    My blog address is located in my "wordpress" folder in the root directory.

    Here is the error I get:

    Fatal error: main(): Failed opening required './wordpress/wp-blog-header.php' (include_path='.:/usr/local/lib/php')

    And it goes on to tell me that the error is on line 2. What am I doing wrong?

    Thanks so much for your help.

    Ryan

  4. Ryan Fitzer
    Member
    Posted 8 years ago #

    By the way, the directory for this page is as follows:

    wordpress/wp-content/2005/2005.php

  5. Ryan Fitzer
    Member
    Posted 8 years ago #

    One more thing. It has it's own folder because it has an images folder and thumbs folder that it draws from. I plan on duplicating these folders in their own directories (2004, 2003, 2002, etc..). This way I do not have to chance any of the HTML. Makes my life a lot easier.

    Ryan

  6. ladydelaluna
    Member
    Posted 8 years ago #

    ./wordpress/wp-blog-header.php isn't going to work since the path to the header isn't in the wordpress folder - it's probably in something like

    /wordpress/wp-content/themes/yourtheme/wp-blog-header.php

  7. Kafkaesqui

    Posted 8 years ago #

    "By the way, the directory for this page is as follows:"

    Then you should try:

    <?php
    require('../../wp-blog-header.php');
    ?>

    Look up "relative paths" in your favorite search engine for helpful info on the topic.

  8. Ryan Fitzer
    Member
    Posted 8 years ago #

    My "wp-blog-header.php" is in my wordpress folder. "header.php" is in my themes folder.

    When I use an absolute path to my header (header.php), some things work but the dynamic content does not show up. Plus, it leaves out the whole template.

  9. Ryan Fitzer
    Member
    Posted 8 years ago #

    Thanks Kafkaesqui and ladydelaluna. Still the same error message.

  10. ladydelaluna
    Member
    Posted 8 years ago #

    try using the entire url - from http onward...

  11. Ryan Fitzer
    Member
    Posted 8 years ago #

    Tried that also. Now it tells me:
    Fatal error: Call to undefined function: get_header()
    I'm going bonkers. That function works when the page is created through the WP Admin. But when I tried to type in the url of any page in my theme directory it says the same thing.

  12. moshu
    Member
    Posted 8 years ago #

    Just for lady:

    wp-blog-header.php and (a theme's) header.php are two (2) very different things!

  13. moshu
    Member
    Posted 8 years ago #

    when I tried to type in the url of any page in my theme directory it says the same thing

    I am not sure I understand this. What exactly are you trying to do?

  14. ladydelaluna
    Member
    Posted 8 years ago #

    i think he's trying to get his theme's header to show up elsewhere, and has saved it in another location... sorry if i misunderstood.

  15. Ryan Fitzer
    Member
    Posted 8 years ago #

    No, the header is in the same place it always has been, my theme's folder. I understand the reason for moshu's solution but it isn't working. Thanks for trying though guys.

    Ryan

  16. ladydelaluna
    Member
    Posted 8 years ago #

    i think the problem is that you're trying to use stuff inside the wordpress theme to make pages outside the wordpress directory...

    why not just install wp on the root dir and then build a blog from that?

  17. Ryan Fitzer
    Member
    Posted 8 years ago #

    All the pages I want to make are in the wordpress directory (sorry for not making that clear in my first post). What I want to do is be able to manually create pages that display a gallery of images (I'm very specific about how that gallery works and do not want to use a plugin). Each page will have a navigation system (drop-down menu) that will lead to the other galleries. I'm basically creating a sub-site to my worpress site.

  18. Ryan Fitzer
    Member
    Posted 8 years ago #

  19. Ryan Fitzer
    Member
    Posted 8 years ago #

    That's without the drop-down.

  20. ladydelaluna
    Member
    Posted 8 years ago #

    Well yeah... your very first post said, "When I create a static page outside of the directory I'm getting errors..." so that's why I was lead to believe what I did.

    I guess what I'm not understanding is why you just don't create a page template just for the galleries... and then make the template do whatever you want it to? You can customize the sidebars and everything just by creating additional ones, and placing them in that specific page template. Then you can use the editor (on the HTML window, perhaps?) to enter your code for the gallery like you want it, without having to build a separate .php page every time.

  21. Ryan Fitzer
    Member
    Posted 8 years ago #

    Sorry. I meant outside my theme's main directory. Each page will have it's own folder (with an images and thumbs folder inside) which will be located in the theme's folder.

    All the image and thumb paths are so simple and I would like to keep it that way (images/1.jpg, thumbs/1.jpg). I could keep the page in the theme's root but then I would have to change every path in the code each time I want to set up a new gallery. I tried to have the main page in the theme's directory and just do an include () for the content. Everything worked except for the images the images.

  22. moshu
    Member
    Posted 8 years ago #

    Are you saying you are putting physical files in the theme's directory? I am not sure that's the best practice. What if you are going to change the theme?
    Wouldn't make more sense to have those files in the WP's root?

  23. Ryan Fitzer
    Member
    Posted 8 years ago #

    I agree with you and have no preference as where they are located. This site is for a friend who will not be changing his theme. If he did I would just create the same thing into the new themes folder and with it's look and feel. That way he could go back and forth.

  24. Ryan Fitzer
    Member
    Posted 8 years ago #

    So I guess I'm at the point now where I'm trying to an include() of a file without changing any of that file's relative links to images. As it is right now, I can get all of the text to show but none of the thumbs or images. You can see it here. You can also click around on the broken thumb links and the javascript functions correctly (the titles change). How do I do this without changing the paths to the images and thumbs? And thank you so much for everyones help sa far.

  25. moshu
    Member
    Posted 8 years ago #

    Oh, I see now. The problem is: incorrect path.
    You have this in your code:
    <img src="images/1.jpg" id="placeholder" />
    but this way you are saying that the /images/folder is in the main=root directory of your WP install, so the browser is looking for the images here:
    http://ryanfitzer.com/wordpress/thumbs/7.jpg
    which obviously is NOT correct.
    What is exactly the path to the "images" folder?
    Is it /wordpress/wp-content/themes/Blix/...and-what?

  26. Ryan Fitzer
    Member
    Posted 8 years ago #

    The path is /wordpress/wp-content/themes/Blix/2005/images. But I don't want to change the path in the code because that would mean changing 48 lines of code everytime I create a new gallery. I've set this code up in a generic manner because it works well in production. It's easier to set up the folder structure to use the code than the other way around. This has worked like a charm on this site. Navigate to the exhibitions page and choose one of the most recent exhibitions. This keeps everything organized beautifully. I name everything in a generic manner (1.jpg, 2.jpg, etc...) and then drop things in the correct folder structure, and violá. I hope you can see why I wouldn't want to change such a good thing.

  27. Ryan Fitzer
    Member
    Posted 8 years ago #

    Ok, so I have given up trying to figure out a php solution. I think the best method will be to create a mini site and then put it in a wp page via an <iframe>. I've looked all over and this does everything I want and is much easier to maintain (I used it before on other sites and I have no idea why I didn't think of it sooner). If anybody knows of any glitches this might cause, let me know. Thanks for everyone's effort.

  28. ladydelaluna
    Member
    Posted 8 years ago #

    iframes are horrid.
    i mean... horrid.
    not all browsers support them. not all visitors support them.
    and search engines hate them.
    iframes are horrid.

    you need to make a few concessions i think. changing the path in the code is worth the effort and time if your only other choice is using iframes.

    did i mention? iframes are HORRID.

  29. Ryan Fitzer
    Member
    Posted 8 years ago #

    Well, crap! I guess I will have to change the paths until I figure out the php problem. I need to get this thing done. Thanks for the heads-up.

  30. Ryan Fitzer
    Member
    Posted 8 years ago #

    So I just ended up using the <iframe> element to get the job done. I know it's not the best solution but damn, it sure does get the job done. I'm going to be working on a better solution in the future and I post it when I figure it out. Maybe a plugin or something. Still learning about all that. Thanks for your help. Here's where I used the <iframe>

    http://chrisjagers.net/wp/?page_id=61

Topic Closed

This topic has been closed to new replies.

About this Topic