forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Themes/Skins/Templates => Topic started by: NeoID on November 12, 2005, 03:21:56 pm

Title: Renameing template.html to php
Post by: 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?
What file do I have to change in order to get the linking correct?

Thanks in advance  ;)
Title: Re: Renameing template.html to php
Post by: Stramm 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
Title: Re: Renameing template.html to php
Post by: NeoID 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...
Title: Re: Renameing template.html to php
Post by: Stramm 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.
Title: Re: Renameing template.html to php
Post by: NeoID 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..  :)
Title: Re: Renameing template.html to php
Post by: Stramm 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
Title: Re: Renameing template.html to php
Post by: NeoID 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?  :-[
Title: Re: Renameing template.html to php
Post by: Stramm 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"?>
Title: Re: Renameing template.html to php
Post by: NeoID 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....
Title: Re: Renameing template.html to php
Post by: Stramm 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.
Title: Re: Renameing template.html to php
Post by: NeoID 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....  ???
Title: Re: Renameing template.html to php
Post by: Stramm on November 13, 2005, 04:12:30 pm
then you've it probably outside your table
Title: Re: Renameing template.html to php
Post by: NeoID 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...
Title: Re: Renameing template.html to php
Post by: Stramm 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
Title: Re: Renameing template.html to php
Post by: NeoID 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...!?
Title: Re: Renameing template.html to php
Post by: Nibbler 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>";
}
Title: Re: Renameing template.html to php
Post by: NeoID 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
Title: Re: Renameing template.html to php
Post by: NeoID 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"  ::)
Title: Re: Renameing template.html to php
Post by: Joachim Müller 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.
Title: Re: Renameing template.html to php
Post by: NeoID 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.
Title: Re: Renameing template.html to php
Post by: Nibbler on November 15, 2005, 03:26:13 pm
If it contains static content then use

Code: [Select]
return file_get_contents('file');
If it contains php code then do

Code: [Select]
ob_start();
include('file');
return ob_get_clean();
Title: Re: Renameing template.html to php
Post by: NeoID on November 15, 2005, 09:28:35 pm
Thanks for the suggestion, but those two commands were the first one I tried and both gives me a blank (white) screen.  :(

Edit: When I put this into the theme.php

Code: [Select]
ob_start();
include('file');

...and this into the template.html

Code: [Select]
return ob_get_clean();
The content of the php shows up on the template fil, but the command wipes everything else..
Title: Re: Renameing template.html to php
Post by: Joachim Müller on November 16, 2005, 12:00:50 am
why don't you post what file.php is suppossed to do instead?
Title: Re: Renameing template.html to php
Post by: NeoID on November 16, 2005, 06:39:41 pm
why don't you post what file.php is suppossed to do instead?

I want to include a php file(s) that allows me to get information from my phpbb forum. I've included two files (there are more)
that gives an example of what I mean. While the engine file connects to the forum, the newposts file shows the actual content.
Title: Re: Renameing template.html to php
Post by: Joachim Müller on November 16, 2005, 06:53:15 pm
The database connectors of phpbb and cpg will interfere, you can't do that. If you have bridged coppermine and phpbb already, you won't have to connect twice to phpbb. You simply can't include anything.