Author Topic: Parsing PHP in skins  (Read 4035 times)

Offline forkless

  • Newbie
  • *
  • Posts: 5
Parsing PHP in skins
« on: February 10, 2010, 03:41:17 AM »
Hi there,

I'm currently trying to personalize the skins for the different domains it is running on however I can't seem to get the PHP parsed in the html located in the skins folder.

- The handlers in .htaccess have been appropriately set
- A plain html page with php inclusion will run fine
- The main.inc.php has the $rcmail_config['skin_include_php'] config setting set as true (tried both true and TRUE, shouldn't really matter I suppose)
- Both releases I run 0.2 and 0.3.1 show this behaviour
- PHP version of the server is 5.2.9

The skin html (snippet from login.html) looks as follows;


<img src="/images/<?php

$getTLD = array_reverse(explode(".",$_SERVER['HTTP_HOST']));
$getTLD = $getTLD[1].".".$getTLD[0];
echo 
$getTLD;

?>.png" 
border="0"


Yet for some reason the PHP doesn't get parsed. Am I missing something here?

Offline alec

  • Hero Member
  • *****
  • Posts: 1,365
Parsing PHP in skins
« Reply #1 on: February 10, 2010, 06:55:31 AM »
Try this instead , you can also create a plugin to set some session variable, and then read it in a skin with

Offline forkless

  • Newbie
  • *
  • Posts: 5
Parsing PHP in skins
« Reply #2 on: February 10, 2010, 11:39:27 AM »
Hi Alec,

Thanks for your quick response. I see what the config variable actually does now! (So much reading eh ;))

Anyways, I created a getdomain.php file for the 0.2 release box and included the tag with the template I want to use it in. However that did not seem to work. For testing purposes I've included it out and inside of a tag which didn't seem to make any difference. Am I correct in thinking that when I invoked the include file relatively it will take the actual file from the active templates folder? If so that did not work.

Next step was to try and point it to an absolute path. No difference either, unfortunately. So I'm a bit stumped at why it does not want to pick up the PHP bit.

Will be trying this on the 0.3.1 release next. Will post the results in a bit. Well just tried 0.3.1 as well and doesn't seem to want to eat that include either. Hope somebody else (or you) may be able to shed some more light onto this.

Thanks again for your input,
fork
« Last Edit: February 10, 2010, 11:52:46 AM by forkless »

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,882
    • SKaero - Custom Roundcube development
Parsing PHP in skins
« Reply #3 on: February 10, 2010, 12:00:16 PM »
The include path is relative to the skin folder /skins/ so if you wanted the templates folder it would be /templates/ Just should how much we need skin documentation :)

Offline forkless

  • Newbie
  • *
  • Posts: 5
Thanks xD
« Reply #4 on: February 10, 2010, 12:07:13 PM »
Quote from: skaero;25418
The include path is relative to the skin folder /skins/ so if you wanted the templates folder it would be /templates/ Just should how much we need skin documentation :)


Sweet! That did the trick for me :D

Thanks for both your efforts!

Offline forkless

  • Newbie
  • *
  • Posts: 5
Parsing PHP in skins
« Reply #5 on: February 10, 2010, 01:28:21 PM »
Quote from: skaero;25418
The include path is relative to the skin folder /skins/ so if you wanted the templates folder it would be /templates/ Just should how much we need skin documentation :)


I have one small question regarding nesting tags. When I add an include as shown below;

<div id="header"><roundcube:button command="mail" image="/images/<roundcube:include file="/templates/getdomain.php" />.png" alt="Roundcube  Webmail" /></div>


I will get the following HTML output;

<div id="header"><a href="./?_task=mail" onclick="return rcmail.command('mail','',this)"><img src="skins/default/images/<roundcube:include file=" id="rcmbtn104" alt="" /></a>.png" alt="Roundcube Webmail" /></div> 

Apparently it does do a partial parse but then it gets killed (escaping problem maybe?)

Now my question is are nested roundcube tags not supposed to work by design or did I stumble onto a bug?

Offline alec

  • Hero Member
  • *****
  • Posts: 1,365
Parsing PHP in skins
« Reply #6 on: February 11, 2010, 03:05:06 AM »
It's not working by design.

Offline forkless

  • Newbie
  • *
  • Posts: 5
Parsing PHP in skins
« Reply #7 on: February 11, 2010, 04:29:14 AM »
Cool, no problem. Good to know though -)