Jump to content


Photo

Allow Editable PHP Variables Dreamweaver Templates


  • Please log in to reply
2 replies to this topic

#1 dleight

dleight
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 03 May 2004 - 11:00 PM

Hi,

I'm a PHP developer who is relatively new to Dreamweaver. I am setting up Dreamweaver templates for one my clients who will be using Dreamweaver to edit/add pages. I have set-up editable HTML regions, but I'd like to know if there is a way set-up a PHP variable such that only the value is editable. For example, in the following code:

<?
     $page_name = 'Contact Us';
?>

I would like the user to be able to change "Contact Us" to whatever they would like, but not to be able to change the PHP code. Is this possible with Dreamweaver MX 2004?

Any help is greatly appreciated.

Daniel Leighton

#2 72dpi®

72dpi®
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 18 May 2004 - 11:57 AM

Hi there,

I am on the other end of the stick :P
I am designer/learning php.

Anyhow, I really suggest you look into Contribute by Macromedia. This package will let the client edit only what you specify in Dreamweaver as editble/non editble, plus allows them to upload/download the pages directly via secure ftp. This way, they can easily update..(worthwhile looking @).

Anyhow, to answer you question, If you use dreamwesver editble/non editle tags, It will surely disrupt your <?php ?> tags.
The solution IMO, may be in the user creating new pages from a template (that you have designed), then they can save as a new page. Then, so they don't need to add to the menu, they can save to a specified folder, such as "content", then set your navigation to build dynamically, such as:

<?php

// thanks to lixlpixel for this

$dir = './content';

$dh = opendir($dir);
while($file = readdir($dh))
{
    if ($file != '.' && $file != '..') // add filter here ...
       // for example  && substr($file,0,-4) != '.txt' to filter out text files
    {
        $dname[] = $file;
    }    
}

sort($dname);
reset ($dname);

// we have an array $dname here now ...

for ( $i = 0; $i < count($dname); $i++ )
{
    
    // bold if its the active you will want to change the index.php to page_self or similar
    if(substr($dname[$i],0,-4) == $_GET['page']) echo '<b><a href="$PHP_SELF?page='.substr($dname[$i],0,-4).'">'.substr($dname[$i],0,-4).'</a></b><br />';
    else echo '<a href="$PHP_SELF?page='.substr($dname[$i],0,-4).'">'.substr($dname[$i],0,-4).'</a><br />';
    
}
?>

and have a content designated area for the content, called "page", as such:

<?
switch ($page) {
# start of main profile categories
   case "profile":
       include('content/profile.txt');
       break;
   case "directors":
       include('content/directors.txt');
       break;
   case "advertisers":
       include('content/advertisers.txt');
       break;
# this is default if file not present
   default:
       include('content/start.txt');
}
?>



But this is the part I am trying to make dynamic, so the switch cases, get built dynamically like the menu. I know this may be off course a bit, but it bascically heads in your direction. That way the content they update, could simply be a text file with all the html stripped out. Then the pages could have headers etc. < mebbe you may come up with a gr8 soulution?

I hope I haven't gone off the beaten path,
:(
_root.ofall.evil
| SiteUnseen Student Photography

#3 Milshak

Milshak
  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 20 May 2004 - 08:21 PM

try putting the variables in an include file such as configure.php




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users