[Solved]: PHP [Solved]: PHP
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[Solved]: PHP

Started by formulx, March 21, 2008, 08:10:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

formulx

Ive gone through the documents but im still having trouble getting used to the templating system used by CopperMine. One of the problems I'm having is finding a way to use PHP in the templates.

Now I realize that the template.html file cant have PHP in it, for obvious reasons but what would I do if I wanted to put in PHP?

I notice there are the {TAGS} but how do I go about creating my own and what are the limitations on them?

I need to include external php files into my template and use code that checks if a user is logged in. I have it all ready to go but cant seem to find an easy way to do this. I hope someone can help me :)

Thanks!

steveeh131047

The easiest way is to use Admin Config to enter the path to your PHP file in the "Themes Settings"  "Path to custom header include" or "Path to custom footer include" fields. Your PHP will then get called where the {CUSTOM_HEADER} and {CUSTOM_FOOTER} tokens show in the template.html file.

This opens up the ability to put a whole bunch of extra stuff in!

formulx

Ah I didnt think of that, thanks Ill try that and see if that works.

Also ive noticed that after placing the {GALLERY} tag any tables or text placed AFTER that are omitted and only any tables started before are closed or finished off. Is this a bug or is there any way around that? As I want to have some more text and such in a table after the gallery tag.

steveeh131047

I've had no problem generating extra content using PHP invoked through the {CUSTOM_FOOTER} token, positioned after {GALLERY}. But I'm not using tables - all my layout is done using CSS!

formulx

It worked like a charm :D Now to figure out how to edit the gallery tag parts to match my theme. Thanks!

steveeh131047

If it helps, I used the HTML from one of my existing site pages as the theme template. I stripped out the main content, but kept the Banner and navigation blocks, and used the existing style sheet. At that stage I'd got my usual site page with a blank where the content would normally be.

I then inserted the cpg tokens, in particular {GALLERY} , in the <div> where my content usually goes. I then tweaked my style sheet to get the cpg colours and fonts to match the rest of the page.