adding php pages adding php pages
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

adding php pages

Started by madmanbean, January 19, 2007, 12:55:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

madmanbean

Rather new to all this and have just installed the excellent chaoticsoule template. I would love to produce some more pages using this template but blank with an editable area within them (ie a dwt based page) and still use php so that those pages are inaccessible unless a user has registered and logged on. Been playing around with this and cannot work out how to edit an existing php page to create an aditable area.

Any help much appreciated.

Thanks Terry

Gizmo

#1
The easiest way would be to add new pages and add a link to them in the $template_user_admin_menu. Since this menu is only available to registered users, it's very easy. There are other ways but more coding is involved.

For example, create a new page as in the above link and call it test.php. Then copy and paste this code from the sample theme.php into your theme.php file if it's not already there.

// HTML template for user admin menu
$template_user_admin_menu = <<<EOT
                                         <h3>User Admin Menu</h3>
                                         <ul>
                                            <li><a href="albmgr.php" title="{ALBMGR_TITLE}">{ALBMGR_LNK}</a></li>
                                            <li><a href="modifyalb.php" title="{MODIFYALB_TITLE}">{MODIFYALB_LNK}</a></li>
                                            <li><a href="profile.php?op=edit_profile" title="{MY_PROF_TITLE}">{MY_PROF_LNK}</a></li>
                                            <li><a href="picmgr.php" title="{PICTURES_TITLE}">{PICTURES_LNK}</a></li>
                                         </ul>
                                           
EOT;


Then add the link like this

// HTML template for user admin menu
$template_user_admin_menu = <<<EOT
                                         <h3>User Admin Menu</h3>
                                         <ul>
                                            <li><a href="albmgr.php" title="{ALBMGR_TITLE}">{ALBMGR_LNK}</a></li>
                                            <li><a href="modifyalb.php" title="{MODIFYALB_TITLE}">{MODIFYALB_LNK}</a></li>
                                            <li><a href="profile.php?op=edit_profile" title="{MY_PROF_TITLE}">{MY_PROF_LNK}</a></li>
                                            <li><a href="picmgr.php" title="{PICTURES_TITLE}">{PICTURES_LNK}</a></li>
                                            <li><a href="test.php" title="Test Page">Test Page</a></li>
                                         </ul>
                                           
EOT;


Let us know how you make out so that others will benefit from this.
Did you read the manual first???? Taking 2 minutes to backup your files can save you hours of wondering what you screwed up.
Billy Bullock - BullsEyePhotos Blog of Indecision

madmanbean

Thanks I will report back..promise to backup before I start!!

madmanbean

OK..have managed to create a page that has the same layout etc but when I open it rather than ask for the user and password like logon.php it is a normal page with the right theme without the gallery bits. It would be great if that could include the logon script like all the other pages prior to logging in. Below are the pages.. I called it test2.php and code is below.

As you will see from the link below the ability to logon and keen every page private is essential as this site is for a swingers club and before you ask I am not a member!!!

see http://www.swing-bandb.co.uk/gallery/test2.php

<?php
define('IN_COPPERMINE', true);
define('LOGIN_PHP', true);
require('include/init.inc.php');
pageheader('Your page title goes here');
// your actual page content starts here
    starttable("100%", 'Content block title', 1);
    ?>
<link href="themes/chaoticsoul/style.css" rel="stylesheet" type="text/css">

    <tr>
    <td class="tableb" valign="top" align="center">
    this is a test page to see where the text would go
    </td>
    </tr>
    <?php
    endtable();
// your actual page content ends here
pagefooter();
ob_end_flush();
?>


Gizmo

OK, I can see the need for this. The first way was simply not to show the link to unregistered users. So in your test2.php file, after this line
require('include/init.inc.php');
add

if (!USER_ID) {
    cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}
Did you read the manual first???? Taking 2 minutes to backup your files can save you hours of wondering what you screwed up.
Billy Bullock - BullsEyePhotos Blog of Indecision

madmanbean

Great. Tnaks a bunch that seems to have done it! II will report back when the site is a little more sorted and feel that this bit of code may be of use to a number of people.
GOD! I just wish I had this grasp of php.

Thanks again


madmanbean

Pushing my luck here..now have a php page that requests a password for those not logged in and have now tried to make this page a .dwt page that can include an editable area for my client. Have done php template pages before but having trouble with the layout of my new template page.
The ammended test2.php file is below and below that the template page produced

<?php
define('IN_COPPERMINE', true);
define('LOGIN_PHP', true);
require('include/init.inc.php');
if (!USER_ID) {
    cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}
pageheader('Your page title goes here');
// your actual page content starts here
    starttable("100%", 'Content block title', 1);
    ?>
<link href="themes/chaoticsoul/style.css" rel="stylesheet" type="text/css">
    <tr>
    <td class="tableb" valign="top" align="center">
    this is a test page to see where the text would go
    </td>
    </tr>
    <?php
    endtable();
// your actual page content ends here
pagefooter();
ob_end_flush();
?>

TEMPLATE PAGE BELOW

members_text.php


<?php
define('IN_COPPERMINE', true);
define('LOGIN_PHP', true);
require('../gallery/include/init.inc.php');
if (!USER_ID) {
    cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}
pageheader('Your page title goes here');
// your actual page content starts here
    starttable("100%", 'Content block title', 1);
    ?>
<link href="../gallery/themes/chaoticsoul/style.css" rel="stylesheet" type="text/css">
    <tr>
    <td class="tableb" valign="top" align="center">
    <!-- TemplateBeginEditable name="body_text" -->body_text<!-- TemplateEndEditable -->
    </td>
    </tr>
    <?php
    endtable();
// your actual page content ends here
pagefooter();
ob_end_flush();
?>

as you can see the basic page now works (see http://www.swing-bandb.co.uk/gallery/new_test.php) but whena  page is created from a template page the formatting has changed with the text being larger in the editable area and it is also offset to the left when compared to the original page
see http://www.swing-bandb.co.uk/gallery/test2.php

Rather hoping that an answer can be given..

Promise your credits will remain forever you have already been a great help!

Thanks Terry





Gizmo

Both links look OK in Firefox but if you check the source output in IE, you find this as the first line in new_test.php
<!-- InstanceBegin template="/Templates/members_text.dwt" codeOutsideHTMLIsLocked="false" -->

This shouldn't be there.

Off to play basketball.  :D
Did you read the manual first???? Taking 2 minutes to backup your files can save you hours of wondering what you screwed up.
Billy Bullock - BullsEyePhotos Blog of Indecision

madmanbean

thnaks for the rapid response.. yes this seems to be a problem as that line of code is generated by dreamweaver when creating a template and cannot be removed without messing up the template! ie you start with the newtest.php page, save it as a template (.dwt) and that code apears

below is the template page that produced new_test.php

<?php
define('IN_COPPERMINE', true);
define('LOGIN_PHP', true);
require('../gallery/include/init.inc.php');
if (!USER_ID) {
    cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}
pageheader('Your page title goes here');
// your actual page content starts here
    starttable("100%", 'Content block title', 1);
    ?>
<link href="../gallery/themes/chaoticsoul/style.css" rel="stylesheet" type="text/css">
    <tr>
    <td class="tableb" valign="top" align="center">
    <!-- TemplateBeginEditable name="body_text" -->body_text<!-- TemplateEndEditable -->
    </td>
    </tr>
    <?php
    endtable();
// your actual page content ends here
pagefooter();
ob_end_flush();
?>

would be ggod to crack this but if the worst comes to the worst I can simply repoduce the working page without editable areas.

bet you play basketball better than me as well as understand php!!

Appreciate your help as usual

Regards Terry