Renameing template.html to php Renameing template.html to php
 

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

Renameing template.html to php

Started by NeoID, November 12, 2005, 03:21:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NeoID

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  ;)

Stramm

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

#2
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...

Stramm

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

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..  :)

Stramm

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

NeoID

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?  :-[

Stramm

Quote from: NeoID 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?

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


<?php echo "Hello world"?>

NeoID

Quote from: Stramm on November 13, 2005, 09:16:59 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....

Stramm

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:
function own_code1() {
echo "Hello world<br>";
}


in functions.inc.php find function load_template() and add this to the similar lines
$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

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....  ???

Stramm

then you've it probably outside your table

NeoID

Quote from: Stramm on November 13, 2005, 04:12:30 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...

Stramm

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

#14
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...!?

Nibbler


function own_code1() {
echo "Hello world<br>";
}


That should be


function own_code1() {
return "Hello world<br>";
}

NeoID

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

NeoID

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"  ::)

Joachim Müller

#18
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.

NeoID

Quote from: GauGau 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 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.