Jump to content

Allow Editable PHP Variables Dreamweaver Templates


Recommended Posts

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

Link to comment
Share on other sites

  • 2 weeks later...

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,

:(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.