Forum Moderators: coopster
e.g. Could the script look for special tags in the html page like <---xyz--->
something like this:
HTML PAGE TO EDIT
<---html code start--->
code here
<---html code end--->
<---text start--->
text here
<---text end--->
<---html code start--->
code here
<---html code end--->
<---text start--->
text here
<---text end--->
<---html code start--->
code here
<---html code end--->
I am new to php, can anyone point me in the right direction as to the kind of commands to do this?
The work I've done recently has been laid out such:
/public_html/index.php
This file contains less than 10 lines, sets a few variables, and "includes" a template page. There is either a page like this for every page of the site, or some "?" trickery to make it show the right page at the right time.
/content/layout.txt
This is my layout template for the site. All pages that follow the basic form start from this. It is mostly html, with a <?php include($this-pages-content-file); ?> in the middle, and <?php echo $this-pages-title; ?> at the top.
/content/index.txt
This page, for example, would have the content for the index page. This is an html fragment page that holds the guts for the page. There is another page like this for every page on the site.
1. Read an html page.
2. Present a form with the text content in text boxes for the client to edit and hit the 'update' button.
3. Re write the html page with the new text.
I would like to avoid 'includes' as I have heard that php pages can get a lower rank on SEs.
My client will go to his secure 'Update tool' (php) - which rewrites their html pages.
On the other hand, its actually a good idea to do things the way you were mentioning (with static pages that are changed by php) since that will protect you from having too much processor usage in the event of high traffic. What you would need to do is open the file in question for reading using:
$file_index = fopen($filename,'r')
I think you then read it into a string with:
string buffer = fread(file_index, sizeof($file_index))
then close your file:
fclose($file_index)
Then, I think you can scan through the string looking for the specific location of a substring using:
strstr($needle,$haystack)
Once you found the beginning and ending index of the string you want to replace, use
substr(beginning,end)
to extract the string and output it in the form.
Then when the user submits his input, you just open your file for writing:
fopen($filename,'w')
and start dumping text into it.
Its actually quite a pain to write the script, but if you over generalize it, you'll only have to do it once.
Go to [sourceforge.net...]
you will most likely find what you need.
Will this affect SEO? If I have these tags inside <H1> or <P> tags
I know I can't expect great SEO with my clients updating their own pages (I give them some basic lessons). I just want to know if say Google would get upset about such tags within <H1> or <P> tags