GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Webmaster Q & Fuckin' A (https://gfy.com/forumdisplay.php?f=27)
-   -   Dynamic content with PHP or javascript (https://gfy.com/showthread.php?t=1103292)

redmark 03-16-2013 08:26 AM

Dynamic content with PHP or javascript
 
Hi everyone

I'm working on my new site (a free pics and vids), is there another way to built a dynamic site then using PHP because i don't want to rename all my pages to .php . I saw other websites with dynamic menu, ad space, refferrer list... all the stuff added to all pages of the site and they use .html

If they use javascript to add HTML to their pages, how it work, because when check the source code of their pages, I see HTML codes. Is Google bot can see their HTML codes for SEO reasons?

I want to use javascript to include HTML codes to my pages like I did with PHP
Maybe I miss something, I need some help, Thanks

Kostly 03-16-2013 09:41 AM

You need .htaccess to remove the .php

hulker 03-16-2013 09:41 AM

Actually you miss a lot of things. :upsidedow You can set up your webserver to parse html files for php code very easily. Or you can set up your webserver to call the equivalent .php document if you call an .html ( like index.html still points to an index.php ) . And a few more options.

redmark 03-17-2013 11:58 AM

What most webmasters do to include html code to their pages like a menu on top of every pages of the site that can be updated without manually change all these pages.

What is the right way to do this for seo, server speed and user friendly

I need step by step details for server configuration
Thanks in advance

robber 03-24-2013 07:22 PM

Quote:

Originally Posted by redmark (Post 19532449)
What most webmasters do to include html code to their pages like a menu on top of every pages of the site that can be updated without manually change all these pages.

What is the right way to do this for seo, server speed and user friendly

I need step by step details for server configuration
Thanks in advance

Showing Pages as .htm

Ok you have two methods, you could use .htaccess to map all the .php files to be .htm, but this involves using a reasonable structure as the rules can be fiddly if you have a lot of subdirectories of different depths that you need to display content from.

or as previously suggested get the server to parse all .html / .htm files as php. This is something which can backfire if you're not careful as it will evaluate all .html / .htm files, which could slow the server down if it's only a handful which need to be php.

Showing standard menu across top of site

You can either create a standard template and have that used across the site, then you only need to update the template (this involves some forward planning, but can be good if you what to have a dynamic site).

Or you can include the menu on all the pages you need (same with the footer info), to do this you can write it as

Code:

<?php
  @include_once("menu.php"); # For your menu
  @include_once("footer.php"); # For your footer
  # ..... you can carry this on for as many elements you want.
?>

What I do

Personally I would create one template and then link all the pages up and feed them in through $_GET[] in the url's and it would have the page names being mapped by a .htaccess file using mod_rewrite functions. It might sound a little complicated to start with but it will pay off if you're creating a site which needs to be able to grow and expand quickly without the need to create every single page, take for example http://livegfcam.com this creates all the pages and links you see dynamically, all I have done is write the template, directory mapping and layout, if you looked at the server there are only a handful of files and the directories you see in the URL do not exist.

I use this solution as I know php well enough to be able to create a lot of my content on the fly, what I would suggest is to think about what you want to do, google the question then if you can't understand the answer either post on the forums or if you don't want to do that, you can always drop me an email rob [at] foxydrop [dot] com

An example from a project I'm currently doing (edited down to remove some of my features so you can get an idea)

Example

index.php

Code:

<?php

ob_start();

## FTGP V 2.0 :D ##

@require_once("config.php");
$url = str_replace("www.","",$_SERVER["HTTP_HOST"]);

$sq = @mysql_query("select * from sites where address='".$url."' limit 0,1");
$tgps = @mysql_fetch_assoc($sq);

$sitename = $tgps['title'];

?><html>
<head>
<title><?php echo $sitename; ?></title>
<link href="/style.css" rel="stylesheet">
</head>
<body>
<img src="/title/<?php echo $tgps['title']; ?>.jpg" alt="<?php echo $sitename; ?>">
<div id="wrapper">
<?php
        if($_GET['page']== "index" || empty($_GET['page'])) $_GET['page'] = "home";
        if(file_exists($_GET['page'].".php")){
                include_once($_GET['page'].".php");
        } else {
                include_once("home.php");
        }
?>
<div style="clear:both"></div>
</div>
<div id="foot">
        <!-- Footer info here -->
</div>
<span style="clear:both">&nbsp;</span>
</body>
</html><?php

ob_end_flush(); ?>

.htaccess

Code:

#start .htaccess code
## FTGP 2 by FoxyDrop.com ##

RewriteEngine On
RewriteBase /

####### Security #######

<FilesMatch ?\.(htaccess|htpasswd|ini|pg|eps|log|sh)$?>
Deny from all
</FilesMatch>

## Lock Directories ##

Options -Indexes -MultiViews +FollowSymlinks

## Hotlink Protection

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?(top\.)?foxydrop.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]

####### House Keeping #######

## Error Pages ##

ErrorDocument 401 /?pg=404&error=401
ErrorDocument 403 /?pg=404&error=403
ErrorDocument 404 /?pg=404&error=404
ErrorDocument 500 /?pg=404&error=500

####### Clean URLS #######

## General ##

RewriteRule ^([^/\.]+).htm?$ index.php?page=$1 [L]
RewriteRule ^sitemap.xml?$ sitemap.php [L]

The above are simple examples the actual files are much more indepth as I have multisite templates which span across a wide number of sites. I've removed a lot of the .htaccess file and parts of the template as they are all the extras like my actual footer and all my tracking and ad details, as well as the additional network sites.

Also just to point out the actual working parts of the site like the actual pages which are being included are the ones which have most of the code in this is just the template part of the site.

Hope this helps

Rob

Mark.Roy 04-06-2013 10:00 PM

for dynamic content site, you need to use php.

and if you want html as an extension then you need to use htaccess rewrite rules.

or you can add single line in httpd.conf on your server to treat .html files as .php files.

this way you can create php coded files with .html extension like you said.

good luck.


All times are GMT -7. The time now is 04:51 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc