Make a custom CPG page Make a custom CPG page
 

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

Make a custom CPG page

Started by lasa, October 16, 2003, 02:24:26 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

lasa

How can I create a custom page in CPG with the header and footer of CPG?

Rodinou

Don't understand really :)

Put some content of CPG in other page (so ... your site mainpage or other section) ?

or

Change the layout of CPG ?

lasa

No, I want to make a custom page, within CPG:
I have already some code:

<?php 
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.2.0                                            //
// ------------------------------------------------------------------------- //
// Copyright &#40;C&#41; 2002,2003 Gregory DEMAR <gdemar@wanadoo.fr>                 //
// http&#58;//www.chezgreg.net/coppermine/                                       //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team                                        //
// &#40;http&#58;//coppermine.sf.net/team/&#41;                                          //
// see /docs/credits.html for details                                        //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify      //
// it under the terms of the GNU General Public License as published by      //
// the Free Software Foundation; either version 2 of the License, or         //
// &#40;at your option&#41; any later version.                                       //
// ------------------------------------------------------------------------- // 

define&#40;'IN_COPPERMINE', true&#41;;

require&#40;'include/init.inc.php'&#41;;

pageheader&#40;'laurens'&#41;;
starttable&#40;"100%", $lang_ecard_php['title'&#93;, 3&#41;;

echo <<<EOT
        <tr>
                <td class="tableh1"><h2>Nieuws</h2></td>
        </tr>
        <tr>
                <td class="tableh2"><b>Test1</b>
                </td>
        </tr>
        <tr>
                <td class="tableb" valign="top">
                Test2        <br />
                </td>
        </tr>

EOT;


endtable&#40;&#41;;
pagefooter&#40;&#41;;
ob_end_flush&#40;&#41;;

?>

lasa

I have now a nice custom CPG HTML page, but I want to include PHP...
How to do it?

Joachim Müller

I don't get the question. What do you mean it's supposed to do? Isn't echo already a php command? How much more PHP does it have to be?
Maybe something like this

// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.2.0                                            //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2003 Gregory DEMAR <gdemar@wanadoo.fr>                 //
// http://www.chezgreg.net/coppermine/                                       //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team                                        //
// (http://coppermine.sf.net/team/)                                          //
// see /docs/credits.html for details                                        //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify      //
// it under the terms of the GNU General Public License as published by      //
// the Free Software Foundation; either version 2 of the License, or         //
// (at your option) any later version.                                       //
// ------------------------------------------------------------------------- //

define('IN_COPPERMINE', true);

require('include/init.inc.php');

pageheader('laurens');
starttable("100%", $lang_ecard_php['title'], 3);

function myfunction()
{
print "How much PHP do you need?";

}

myfunction();

endtable();
pagefooter();
ob_end_flush();

:lol: GauGau

Tarique Sani

@ Gaugau - any chance of the PHP bbCode not putting in <?php and ?>

I am usually posting lines which do not have them and dont need them...
SANIsoft PHP applications for E Biz

lasa

Thank you for the code!

Edit:
And how can I show only this page if the user who visit this page is an administrator?

Joachim Müller

@lasa: at the top of the file, after the require statement, put inif (!GALLERY_ADMIN_MODE) die('Access denied');. To only show it to an admin, you'll also have to edit your navigation, look for /themes/yourtheme/theme.php and check the admin menu.

@tarique: I'll put this on my todo list

GauGau

lasa

Thnx!

Edit:
How can I make a link that only shows up in the main menu when te user is an logged-in-admin?

Joachim Müller

you can't, that's what the admin menu is for (well, actually you could, but this'd require some thinking about it, some testing etc. and I just don't see the point in this, so if you can't figure this out for yourself, you're stuck).

GauGau

lasa

Can I add this code:

if (!isset ($preview)) {
  $preview = '0';
}

if (isset ($_POST["submit_add"])) {
  $preview = '0';
  $date_input = @gmdate('YmdHi', time() + (3600 * 2));

  $query = "INSERT INTO weblog VALUES ('','$title_input','$text_input','$date_input','$loggedin_id','$submitted')";
  $exec = mysql_query($query);

  echo '<script>location.href="index.php"</script>';
}

else {
  if (!isset ($title_input) OR !isset ($text_input)) {
    $title_input = "";
    $text_input = "";
  }

  $title_input = ereg_replace( "['\"\]", "", $title_input);
  $text_input = ereg_replace( "['\"\]", "", $text_input);

  include "logo.php";

  echo "<title>Weblog - Add item</title>
  <div id='main'>
  <form method=post action='customcpgpage.php?preview=1'>
  <table cellspacing=0 cellpadding=0 width=100%>
  <tr>
  <td class='header'>
  <b>Add item</b>
  </td>
  </tr>
  <tr>
  <td class='weblog'>
  <table>
  <tr>
  <td class='form'>
  title:
  </td>
  <td class='form'>
  <input name=title_input type=text value='$title_input' size=30 maxlength=25>
  </td>
  </tr>
  <tr>
  <td class='form'>
  text:
  </td>
  <td class='form'>
  <textarea name=text_input>$text_input</textarea>
  </td>
  </tr>
  </table>
  <input name=submit_preview type=submit value=preview>
  </td>
  </tr>
  </table>
  </form>
  ";
}

if ($preview == '1') {
  if ($title_input != "" AND $text_input != "") {
    $preview_date = get_date_long(@gmdate('YmdHi', time() + (3600 * 2)));
    $preview_text = ubb_advanced(ubb_basic(nl2br(htmlspecialchars($text_input))));

    echo "<form method=post action='customcpgpage.php'>
    <table cellspacing=0 cellpadding=0 width=100%>
    <tr>
    <td class='header'>
    <b>$title_input</b>
    </td>
    </tr>
    <tr>
    <td class='weblog'>
    <b>$preview_date</b> posted by <a href=''>$loggedin_name</a>
    <hr>
    $preview_text<br><br>
    <input name=title_input type=hidden value='$title_input'>
    <input name=text_input type=hidden value='$text_input'>
    <input name=submitted type=hidden value='0'>
    <input name=submit_add type=submit value=submit>
    </td>
    </tr>
    </table>
    </form>
    ";
  }

  else {
    echo "<table cellspacing=0 cellpadding=0 width=100%>
    <tr>
    <td class='header'>
    <b>Error</b>
    </td>
    </tr>
    <tr>
    <td class='weblog'>
    Both fields are required.
    </td>
    </tr>
    </table>
    ";
  }
}




Into that function?

function myfunction()
{
print "How much PHP do you need?";

}

Joachim Müller

as I said: it's anycontent, you can add anything. I won't look over your code - if you want to learn PHP, start at http://php.net/ and get the manual.

GauGau

lasa

Okay.
I have a new question... How can I display the name of the logged-in-admin? I want that admin's can post news, but I want to display the author of the news.. Do you get it?

Tarique Sani

No -  we don't get it - we Devs are too dumb to understand all this.
SANIsoft PHP applications for E Biz

lasa

My english is very poor.
So if my queston isn't so clear...

I'm not making your team absurd. You are doing a great job by making coppermine better and better. But i'm not self-assured by asking questions in the english language...

Tarique Sani

OK! granted that your English is poor - English is not my first language either BUT Gaugau, in very simple English,  has gone to great lenghts to explain that what you put in anycontent.php may OR may not be related to CPG and  asking questions about that is waste of resources here...

Let me suggest one thing - go to http://php.net download the manual in whatever language you are comfortable with and read every word of it. At the end there will be light :)
SANIsoft PHP applications for E Biz

jriba

I don't mean to "hijack" this thread, but I think that my question is related to this thread's original purpose.  I have also searched the forum, but have found no answers regarding this.

I have made a couple of "custom" pages for my Coppermine website using the code that GauGau posted here and it works great.

I want to put the "breadcrumbs" in these pages.  For example, one of these custom pages I made is a "Contact Us" page.  Another is a "Legal Terms" page.

I would then like the breadcrumbs, just as they appear everywhere else on the site, to appear on these pages, such as:

"Home > Contact Us"    and    "Home > Legal Terms".

How can I do this?  Which function (if it's that easy) outputs the breadcrumbs?

Thanks for your help!

donnoman

your best bet is just output the table using the same css classes.

from 1.21 html output, I put it in callable function.

function my_breadcrumb($href,$title)
{

echo <<<EOT

<table align="center" width="100%" cellspacing="1" cellpadding="0" class="maintable">

       <tr>
               <td class="tableh1"><span class="statlink"><b><a href=index.php>Home</a> > <a href=$href>$title</a></b></span></td>
       </tr>

</table>

EOT;
}