44 users online (2 members and 42 guests)  

Thread: PHP includes


Page 1 of 2 1 2 Last
  Results 1 to 15 of 20

Related

  1. Question about asp includes    Forum: Search Engine Optimization - SEO - Forum
    Replies: 7
  2. Includes!    Forum: HTML Forum
    Replies: 3
  3. Server-side Includes    Forum: HTML Forum
    Replies: 2
  4. quik question reguarding includes    Forum: PHP Forum
    Replies: 0
  5. Need some advice about includes    Forum: Website Scripts Forum
    Replies: 2
  1. #1
    Android's Avatar

    Status
    Offline
    Join Date
    Oct 2002
    Location
    I AM CANADIAN
    Posts
    440

    PHP includes

    (This could be moved to a possibly more relevant forum, but I couldn't figure out which. I just thought that a 'site map' question belonged in an HTML forum.)

    You can use a simple javascript menu that resides in a separate .js file. When you want to update the menu, just update the .js file and all your pages will regenerate automatically.
    Of course the disadvantage of this is that the bots won't pick up the .js, so you will need to include a link on each page to a 'site map' file or something along those lines for the bots to follow.
    I'm considering doing this, but how would one go about doing a 'site map' and linking to it?
    Is a site map just an HTML webpage with the same navigational links on it that's unpublished (unless you give out the url)? Then possibly link to it from every page on your site using some form of invisibility (same colour text as background)?
    I haven't done any searches as yet, I'd just thought it might be a good topic to, um, digest.
    :homer: mmmmm.......bits and bytes. Woohoo....

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Usually sitemaps are the 'safety net' of site navigation. When all else fails, the user can look at your sitemap to find what he needs.

    eg : http://www.ahfb2000.com/
    Last edited by HTML; 03-23-2009 at 04:36 PM.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    forget javascript, use a php include. By using a php include you are not only allowing the spiders to crawl your links, but you open your site up to a whole new realm of options.

    Of course php includes require you to change the extension from html to php, a small price to pay to include...oh say the last 10 forum topics on every page , maybe a whats new section on the main subpages, just change your inc. file and the other pages change automatically to the new and fresh content....and google loves new and fresh

    Dave
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting

  4. #4
    Android's Avatar

    Status
    Offline
    Join Date
    Oct 2002
    Location
    I AM CANADIAN
    Posts
    440

    Talking

    LOL Whoa! PHP? Hmmmmmmm..........then I have to learn something new!
    Is PHP one of those things that you can't have if you're using the webspace generously supplied by you're provider? Or am i confusing that with CGI? Or something else.
    If that's what it takes, I'll learn it, but I probably be better off for now just learning how to do this
    (Know what I mean, know what I mean, say no more, say no more, eh?)

    PS Know any good php tutorial links ?
    Do I need some kind of compiler? Guess I have something to keep me busy tomorrow.

  5. #5
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    You will need to find out if your host supports php, if it does then look no furthur than below for how to do it


    ...of yeah

    step 1: rename your page to have a .php extension instead of html

    step 2: make your file you want included, just plain ole html or anything else.

    step 3: save this file as whatever.inc, it may want to save with a .txt at the end so be careful, just remove the .txt if it does.

    step 3: paste this inot your page you want the include to appear




    <?include "http://www.blah.com/whatever.inc" ?>
    Dave

    changing title and moving to scripts

  6. #6
    benzden's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2002
    Location
    San Antonio, Texas
    Posts
    652
    Why would the process of including a .php renamed file be any more efficient than the already included .js file, for example?

    Shouldn't it be more likely the reliability or bandwidth availability of the host server?

    In other words, if one is having problems getting .js includes loaded and thereby their enhancements to the web page, wouldn't one have the same problems at that host server with any other included files?

  7. #7
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    With JS, being that it is a client side language, it is not as matter of the server but the browser. For this reason spders cannot handle JS or DHTML. PHP, being a server side language, builds the pages before the spider sees it, therefore everything in a PHP include is well, included

    Dave
    AHFBWEB Less customers per server, more power for you!

    Business Class Shared Hosting

  8. #8
    benzden's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2002
    Location
    San Antonio, Texas
    Posts
    652
    My inquiry wasn't necessarily concerned with the "search engine" and spidering process as much as the mere display of the page for visitors. My intent is to eventually switch to a host that allows more reliable all browser friendly includes and that conversion process would appear to be less daunting with the mere .js or .htm to .php renaming process.

    If I understand the process, it means that:

    At present, when one uses "view source" to see inside any of my pages (whether a visitor or spider) only the <SCRIPT ...> calls can be seen. On the other hand, with a .php include, even the data obtained from that included file can be seen.

    Am I understanding it correctly?

  9. #9
    Android's Avatar

    Status
    Offline
    Join Date
    Oct 2002
    Location
    I AM CANADIAN
    Posts
    440

    Question Let me see if I've got this right......

    So a site map is just a page done up in HTML which shows the site's navigation paths, and PHP is a way for the spider to 'see' the navigation of the site in a logical manner by being directed to the site map by the PHP scripting?
    And if my navigation is currently DHTML, the SE spider is going to have difficulty spidering my site otherwise ( outside of my secondary nav links at the top and bottom of every page)?

    I never thought of it, but I guess that's why I see alot of sites that have a link to a site map. I always wondered, if the navigation was straight-forward, why a site map was even necessary.
    My self, I don't think that offering a site map to users would be useful (unless it was one HUGE site) and I might have been tempted to keep it hidden, but now that I think about it, it's a good online record of you're links!
    Too bad there's no emoticon for :impressed:

  10. #10
    sonofmidi's Avatar

    Status
    Offline
    Join Date
    Jan 2001
    Location
    NC, USA
    Posts
    75
    PHP will parse any HTML content you include. This can be an image and even JS. If you include a JS script tag or function, the content generated by the script tag will work as if it was embedded. For all intents and purposes, JS should be limited to specific functions. ie: DHTML/JS hover menus, etc. PHP or ASP should be used for including dynamic content and it will be treated by a search engine as embedded content, even if it is being served on-the-fly from a database. The viewer cannot do a page view and see your PHP code, only the HTML you want echoed.

    Make a script and call it "includes.inc.php" and add this code

    Code:
    <?php
    
    function send_info($var_1)
    {
    	if($var_1 == 'yes')
    	{
    		$_output = 'foo is good';
    	}
    	elseif($var_1 == 'no')
    	{
    		$_output = 'foo is bad';
    	}
    	else
    	{
    		$_output = 'foo is in the middle';
    	}
    	
    	$_source = '<table><tr><td>' . $_output . '</td></tr></table>';
    		
    	return $_source;
    }
    
    ?>
    In your main page which has to have a *.php extension, include the includes.inc.php file:

    <?php include_once 'includes.inc.php'; ?>

    Wherever you want you included content to be displayed, add the function:

    <?php echo send_info('argument'); ?>

    Only the $_source variable will be displayed and exposed in the HTML source.

  11. #11
    benzden's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2002
    Location
    San Antonio, Texas
    Posts
    652
    Right now, I have dozens of .js files in various folders with hundreds of functions, mostly menus tied to specfic subjects, that appear on various sites depending upon that site's content.

    Does converting to a .php process mean that I'd have to have hundreds of distinctly named uniquename.php to cover each of those functions or does the .php include process have something equivalent to the .js <SCRIPT ...>function('var1','var2','etc')</SCRIPT> process?

  12. #12
    sonofmidi's Avatar

    Status
    Offline
    Join Date
    Jan 2001
    Location
    NC, USA
    Posts
    75
    Not necessarily. My example was just my method of running content. You can use your present JS files as is. Let's say you want different JS scripts depending on a users browser.

    ie: this file is "browser.inc.php"

    <?php

    function inc_Header()
    {
    global $_SERVER;

    $_agent = $_SERVER['HTTP_USER_AGENT'];
    $_valid_browser = array('opera 6','opera 7','MSIE 4','MSIE 5','MSIE 6','MSIE 7','Mozilla/5');
    $_set_browser = 0;

    foreach($_valid_browser as $_v)
    {
    if(stristr($_agent, $_v ))
    {
    $_set_browser = 1;
    }
    }

    if($_set_browser == 1)
    {
    $content = '<script src=.....></script>';
    $content .= '<script src=.....></script>';
    $content .= '<script src=.....></script>';
    }
    else
    {
    $content = '<script src=.....></script>';
    $content .= '<script src=.....></script>';
    $content .= '<script src=.....></script>';
    }

    return $content;
    }

    ?>


    In any of your PHP pages:

    <?php include_once 'browser.inc.php'; ?>

    <html>
    <head>
    <title>title</title>
    <?php echo inc_Header(); ?>
    </head>
    <body>
    </body>
    </html>

  13. #13
    sonofmidi's Avatar

    Status
    Offline
    Join Date
    Jan 2001
    Location
    NC, USA
    Posts
    75
    You could also have it include specific JS scripts depending on a domain.

    <?php

    function inc_Header()
    {
    global $_SERVER;

    $_valid_site = array('my_domain.com','my_domain2.com');

    if($_SERVER['HTTP_HOST'] == $_valid_site[0])
    {
    $content = '<script src=.....></script>';
    $content .= '<script src=.....></script>';
    $content .= '<script src=.....></script>';
    }
    elseif($_SERVER['HTTP_HOST'] == $_valid_site[1])
    {
    $content = '<script src=.....></script>';
    $content .= '<script src=.....></script>';
    $content .= '<script src=.....></script>';
    }
    else
    {
    $content = '<script src=.....></script>';
    $content .= '<script src=.....></script>';
    $content .= '<script src=.....></script>';;
    }

    return $content;
    }

    ?>

  14. #14
    benzden's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Feb 2002
    Location
    San Antonio, Texas
    Posts
    652
    In other words, this 'next big change' to my 1000+ web sites is going to again involve making changes to each and every one of those files.

    I also notice that the include is coded before the beginning <HTML> tag - is that de rigueur or could I merely revise the extant <SCRIPT ...> includes now located just before the closing </HEAD> tag?

  15. #15
    sonofmidi's Avatar

    Status
    Offline
    Join Date
    Jan 2001
    Location
    NC, USA
    Posts
    75
    benzden, as a rule of thumb, any included file, session start or class declaration should be at the top of the page. Like HTML and other text files, it is parsed L to R, top to bottom. My suggestion would be to convert to a database CMS. If you are going to have to rename files, update pages, etc, your time is better spent doing it once with the CMS. This way, you can setup base templates and the main content would be inserted from the database. You only need update a couple of templates to update 1000's of dynamic pages. My company's website, http://trilogyaudiometrics.com is run from a CMS. It has a single template called index.php. When I add a new page, it is called by index.php/new_page where new_page is the "id" and uses this to call it from the database. Zaire came up with this as search engines do not like and sometimes will not index a url like index.php?section=new_page. There are search and replace scripts that can do a lot of this work for you if the CMS is not an option.
    Last edited by sonofmidi; 04-16-2003 at 01:29 PM.



Page 1 of 2 1 2 Last

Tags for this Thread