WordPress.org

Ready to get started?Download WordPress

Forums

include php on a page (18 posts)

  1. pmaior
    Member
    Posted 7 years ago #

    OK. I'm stumped on this one. Hopefully somebody can shed some light on this.

    I am attempting to get a php site running in a page on my wordpress site.

    I got the site running correctly in a separate folder. Check it out here.

    http://www.freecookingvideos.com/recipepage

    I got as far as creating a stripped down page template and assigning it to that page. The site comes up but the path is incorrect. It keeps trying to use the blog path instead of the relative path. ie /freecookingvideos instead of /freecookingvideos/recipepage.

    I have tried putting the entire path in the config file of the php site and in wordpress. Nothing works. :(

    Maybe I just can't do this without some plugin but it seems like a simple command somewhere is eluding me.

    here is the code in the page template I am using.
    <?php
    /*
    Template Name: Recipe
    */
    ?>

    <?php get_header(); ?>

    <?php $siteurl= 'http://www.freecookingvideos.com/recipepage'; ?>
    <?php require ('http://www.freecookingvideos.com/recipepage/index.php'); ?>

    <?php get_footer();

    The $siteurl line is probably useless, but it was worth a shot.

    I have even removed the header and footer and still the path stays the same.

    Well back to beating my head against the wall. :?

    here is the link to the blog page.

    http://www.freecookingvideos.com/recipes

  2. moshu
    Member
    Posted 7 years ago #

    In the "require" line you have a URI, not a path!

  3. pmaior
    Member
    Posted 7 years ago #

    Thanks moshu:

    I went and changed it to
    <?php require ('http://www.freecookingvideos.com/recipepage/'); ?>

    But it still goes to the abspath.

    Is there a way to change the path for a page ?

  4. Medizinische Abkuerzungen
    Member
    Posted 7 years ago #

    It's still an Url use something like

    test/test.php (if the file is in the subdir test)
    or

    /var/.../htdocs/wordpress/test.php (if you know the complete path on your webserver)

  5. moshu
    Member
    Posted 7 years ago #

    Also be aware if "recipepage" is a folder - I am afraid it will not work. You use the include to include a file.
    Another issue: If the included file is a complete html page (having its own head, body etc.) then you are looking forward to a lot of validation errors and headache...

  6. pmaior
    Member
    Posted 7 years ago #

    Thanks for the reply moshu & Stefan

    recipepage is a folder. I thought it wise not to mix these files in with the wp files.

    I suppose I could rename some files and put it right in the root. There are many common names that are re-used such as index.php.

    I tried the ezstatic plugin and that made the path /freecookingvideo/recipe

    Without really understanding how the pages work, I would not want to play with that.

    Is it possible to write a plugin to do this or do you know of one available ?

    It is a shame, because I am so close I can taste it.

    I suppose it is possible to include the recipe database in the wordpress database and put the code right into a page. I read about that somewhere. I think that is more work than it is worth at this point though. But if you can point me towards some documentation for doing such a thing, I would greatly appreciate it.

    Thanks again
    Pablo

  7. moshu
    Member
    Posted 7 years ago #

    I have no idea what that script of your does or how does it works. Sorry.
    I know how to make a simple php script to work in a WP template or Page or post; I know how to include a .php file into another.
    However, what you seemingly want: to combine two independent scripts that have their own database and so on.
    Well, for that a simple "include" will not siffice, it will not a bit more work.
    You should post more about the other script you are using (e.g. its source, URL etc.) and about how do you want to make it work together with WP etc.
    Then maybe somebody can help you.

  8. Medizinische Abkuerzungen
    Member
    Posted 7 years ago #

    Perhaps I didn't get it right the first time.

    If you have two different applications in two different paths, the easiest way is this:

    Create themes for both

    Use a static doorwaypage to switch from first to second application. Otherwise you have to process all links to the new application.

  9. pmaior
    Member
    Posted 7 years ago #

    Thanks for the replies all.

    The script is from http://www.easysitenetwork.com/

    It is the recipe site that I am using.

    It is a free download and free to use as long as you leave the link in at the bottom.

    I am fairly competent at using php but by no means an expert. So I can follow basic instructions and troubleshoot most problems by looking at the code.

    I thought getting a ready made script that already works would be easier than creating one from scratch.

    The script is working fine the location it is stored.
    freecookingvideos.com/recipepage

    Stefan: Can you elaborate on the doorway page ? Or point me towards documentation ? I hate to waste peoples time if there is something I can read to answer my questions.

    I know I can always just create a separate page outside of wordpress to accomplish what I need, but prefer to have it all in wordpress if possible, nice and clean.

    Thanks again for your time

  10. moshu
    Member
    Posted 7 years ago #

    I've read the description of that script: except the mailing list/newsletter and "search voyeur" - everything else exist in WP and/or plugins.
    Yes, I konw, it's more work... I just wanted to let you know.

  11. pmaior
    Member
    Posted 7 years ago #

    Moshu:

    I was probably going to get rid of those 2 features anyway.

    But just to clarify, are you saying I could import the recipe database into the wp database and put the php code into a page, or someting similar ?

    I am more interested in what works best not necessarily what is the easiest.

    Thanks

    Pablo

  12. moshu
    Member
    Posted 7 years ago #

    are you saying I could import the recipe database into the wp database and put the php code into a page

    No, I've never said anything like that ;)
    What I said is: from the beginning you did NOT need any additional script, since (almost) everything what that script does could be achieved by WP.
    However, if you already have lots of recipes in that script's database... I am clueless.

  13. pmaior
    Member
    Posted 7 years ago #

    moshu:
    Actually I don't have any recipes in the database. It comes with a bunch though. I would be willing to enter in my own recipes into a new database, but I am not sure what where to begin to set that up in wordpress. I would need a user interface to enter the recipes and a way to display them by category.
    You say all the capabilites exist in WordPress that were in the recipe script, can you point me towards some documentation or maybe sites that are set up like that ?

    Regards

    Pablo

  14. moshu
    Member
    Posted 7 years ago #

    I am a bit confused. I assumed you have a WP site/blog... where every recipe can be a post + every post must be in a category - so I don't see the issue.
    No separate database, no special interface, no complications. I remember several instances in the forum when users were presenting their cooking/recipe blogs.
    Doing a search for recipes or similar keywords, probably, will get you to some examples.

    And this is from the script's site:
    * List recipes by category
    * Rate a recipe functionality
    * Email recipe to a friend functionality
    * Email newsletter signup functionality
    * View top 10 rated recipes
    * Full text search of the entire recipes database
    * Users can create accounts to add their own recipes to your site. Your users provide your content
    * Users can view the recipes they have added and see which are waiting for approval, added or been declined

    As I said, except the newsletter/mailing list everything can be done with basic WP features or plugins. I also added: + work :)

  15. bloodhound
    Member
    Posted 7 years ago #

    I'm havng a similar problem, I think: I want to include a separate PHP file on a capital-P Page. This code does nothing:

    <B>Here are our current contributors...</B>

    <?PHP include 'http://distinctivephoenix.com/Contrib.php' ?>

    Is this simply a matter of using an absolute path, or is callng PHOP from a Page forbidden?

    Thanks!

  16. pmaior
    Member
    Posted 7 years ago #

    Bloodhound: Try putting the url in parens like this
    <?PHP include 'http://distinctivephoenix.com/Contrib.php')?>

    Moshu: I never thought of using posts as the method of storing the recipes. I was hoping to have a database that could be maintained outside of wordpress and accessed from within wordpress.
    Your suggestion is a good one and I will consider using it , at least for the short term.

    Being a relatively new to wordpress, I tend to think more in terms of things I know better like mysql and php.

    My main page/blog is videos of recipes. I wanted to make written recipes separate. Which would still work with your suggestion. I would probably need to make a new set of categories and sidebars for the recipe page though, to keep it clean.

    Thanks for your patience and all your help.

  17. moshu
    Member
    Posted 7 years ago #

    pmaior:
    Bloodhound: Try putting the url in parens like this
    <?PHP include 'http://distinctivephoenix.com/Contrib.php')?>

    Man... the very first thing told to you in this thread was this DOES NOT WORK. For somebody that allegedly knows "better" PHP the difference between an URI and a path should be clear.

    Bloodhound, do not use URI in include, only path. Read the whole thread and you will find examples for distinction.

  18. pmaior
    Member
    Posted 7 years ago #

    Moshu:

    I was referring to the syntax only, not the contents. You are right I should have been more clear. I just copied the text he had in there.However , I did have success with that format as far as the file being included , it just did not work the way I expected, and I can see now that it never will.

    And I never claimed to be an expert, just competent. Like seeing that the parentheses were missing from a function call.

    Sorry for any confusion. I was just trying to be helpful. I will dispense with any further advice unless I have thoroughly tested it my self.

    Pablo

Topic Closed

This topic has been closed to new replies.

About this Topic