Advanced search  

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]

Pages: [1] 2   Go Down

Author Topic: Renameing template.html to php  (Read 11477 times)

0 Members and 1 Guest are viewing this topic.

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Renameing template.html to php
« on: November 12, 2005, 03:21:56 pm »

Is it possible to rename the template.html file to .php so that I may use php within it?
What file do I have to change in order to get the linking correct?

Thanks in advance  ;)
« Last Edit: November 14, 2005, 06:26:36 pm by Nibbler »
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Renameing template.html to php
« Reply #1 on: November 12, 2005, 04:09:19 pm »

no, you can't use php code in template.html
if you really need to have php code executed the first thing to try is anycontent.php. If that's not sufficient you'll have to modify theme.php

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Renameing template.html to php
« Reply #2 on: November 12, 2005, 04:13:11 pm »

Thanks, but how am I supposed to get the php file to show up in the template file?
I'm sorry, but I don't qute understand...

Edit: In order to give you an idea of what I'm thinking, I've uploaded my current design here:
http://animenord.com/galleri/

In between the images to the left (Sorry, I'm norwegian: Nyeste innlegg, partnere and so on ), there is supposed to go a line of
php that allows me to fetch several info from my forum...
« Last Edit: November 12, 2005, 04:20:34 pm by NeoID »
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Renameing template.html to php
« Reply #3 on: November 12, 2005, 04:20:32 pm »

Documentation http://coppermine-gallery.net/demo/cpg13x/docs/index.htm

4.10.3 Album list view
The content of the main page ->
'anycontent': inserts php-generated content that has to reside within the file 'anycontent.php' into the index page. Can be used to include banner-rotation scripts or similar.

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Renameing template.html to php
« Reply #4 on: November 12, 2005, 04:25:16 pm »

I understand that bit, however, after entering everything into the anycontent.php file, how do I specify where the
actual content has to go? Look at the edit from my last post. I'm sorry, but my english is rather bad, and my experiance with
php/coppermine rather bad..  :)
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Renameing template.html to php
« Reply #5 on: November 12, 2005, 04:28:49 pm »

Please read the documentation. Especially 4.10.3 Album list view - The content of the main page

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Renameing template.html to php
« Reply #6 on: November 13, 2005, 12:16:27 am »

I don't think you understand. I don't want to place php with the gallery, but outside.
As you see here: http://www.animenord.com/galleri I want the script to go into the very left hand side.
As far as I understood the documentation, it only tells how to use php within the galleries tables, but how
do I place something php into my own?  :-[
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Renameing template.html to php
« Reply #7 on: November 13, 2005, 09:16:59 am »

Is it possible to rename the template.html file to .php so that I may use php within it?

You asked how to modify coppermine files to add custom php code to it. I answered that. Now you want to know how to add php code to non coppermine files. What shall I say.. it depends, I don't know the file so I can't say exactly. Usually you have something like this

Code: [Select]
<?php echo "Hello world"?>

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Renameing template.html to php
« Reply #8 on: November 13, 2005, 11:36:51 am »

Now you want to know how to add php code to non coppermine files.

Why do you call it "non coppermine files"? Isn't the Template.html a coppermine file? Thats what I'm talking about.
As you see, it's outside the coppermine table, but still within that file..

Thanks for your answer....
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Renameing template.html to php
« Reply #9 on: November 13, 2005, 12:09:56 pm »

that's true... however before you had coppermine in an Iframe -> you want to edit non coppermine files

anyway... here's what you have to do
add your php content as function to theme.php, eg:
Code: [Select]
function own_code1() {
echo "Hello world<br>";
}

in functions.inc.php find function load_template() and add this to the similar lines
Code: [Select]
$gallery_pos = strpos($template, '{OWN_CODE1}');
$template = str_replace('{OWN_CODE1}', own_code1() ,$template);

now add {OWN_CODE1} to your template.html where you need it.

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Renameing template.html to php
« Reply #10 on: November 13, 2005, 04:10:01 pm »

Thanks for your fast reply.
There is just one problem left... "Hello world" is now showing up on template.html,
but it doesn't really matter where I put {OWN_CODE1}, since Hello world always is placed in the upper left
corner of the screen....  ???
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Renameing template.html to php
« Reply #11 on: November 13, 2005, 04:12:30 pm »

then you've it probably outside your table

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Renameing template.html to php
« Reply #12 on: November 13, 2005, 04:18:27 pm »

then you've it probably outside your table

Does that mean I also have to edit the theme.php in the same way as the template.html (the visual editing)? I get the point,
but I can't understand how it's possible to get the {OWN_CODE1} inside the table...  :-\\

If I get it right, it's just possible to add php within the tables of the coppermine gallery? Is it true that I have to add my own tables to the theme.php
in order to get the correct visual result in the template.html

Sorry about my english...
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Renameing template.html to php
« Reply #13 on: November 14, 2005, 08:39:09 am »

no, just try to place the insert tag below {THEME_SELECT_LIST} .. and 'hello world' should appeare there. It needs to be in a correct table setup in template.html

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Renameing template.html to php
« Reply #14 on: November 14, 2005, 01:50:18 pm »

It doesn't matter where I place the code, the "Hellow world" ends up in the top left corner.
I havn't changed the original table setup, so I don't really know what's going on...

I've even tried to modefy the original classic coppermine theme, however, I get the same results...

Edit: Strange... the layout differ if I point my browser to http://galleri.animenord.com/ instead of http://animenord.com/galleri
Maby that has something to do with the problem...!?
« Last Edit: November 14, 2005, 03:32:36 pm by NeoID »
Logged

Nibbler

  • Guest
Re: Renameing template.html to php
« Reply #15 on: November 14, 2005, 03:52:07 pm »

Code: [Select]
function own_code1() {
echo "Hello world<br>";
}

That should be

Code: [Select]
function own_code1() {
return "Hello world<br>";
}
Logged

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Renameing template.html to php
« Reply #16 on: November 14, 2005, 06:25:06 pm »

It worked, thanks alot Nibbler and of cause a big thank you to Stramm!
I guess you can set this thread to solved, I hope it will help other users.  :D
Logged

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Renameing template.html to php
« Reply #17 on: November 14, 2005, 08:55:47 pm »

I'm sorry about replying to a solved topics, but is it possblie to change the "return" to a include statement?
I have a exertnal .php file I want to be shown in the template.html instead of the "hello world"  ::)
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Renameing template.html to php
« Reply #18 on: November 14, 2005, 09:05:02 pm »

sure, if the external file returns the expected. If it echoes, you'll have to temporarily store the output buffer in a var and return that instead.
In other words: depends on your include file. Some coding skills needed. Use trial and error.
« Last Edit: November 15, 2005, 11:59:02 pm by GauGau »
Logged

NeoID

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 49
Re: Renameing template.html to php
« Reply #19 on: November 15, 2005, 02:51:29 pm »

sure, if the external file returns the expected. If it echoes, you'll have to temporarily store the output buffer in a var and return that instead.
In other words: depends on your inculde file. Some coding skills needed. Use trial and error.

Example:
The file "file.php" contains exactly what I want to output on the template.html, could you please give me an example of how
I may write it in order to get the content to show on the template? I've asked a lot of people, however, nobody knew the answer,
or it didn't work.

Thanks.
Logged
Pages: [1] 2   Go Up
 

Page created in 0.024 seconds with 21 queries.