PDA

View Full Version : $cur_template


Digital X
February 16th, 2004, 18:29
same question .. different words .. :lol:

when working with modules like ..

CJ Tagboard or Hangman ..

that have iframes that call a source file ...

src=modules/mod_tagboard/display.php ... or
src=modules/mod_hangman/hangman.php ...

how do i get these files to call the "current templates" /css/template_css.css

<?php echo $cur_template; ?> does not work ....

for all that is sacred and holy .. would someone please help me find the answer .. lol ... ive been trying to figure this one out for three days now ...
i wake in the middle of the night screaming "CURRENT TEMPLATE !!" ... lol

tonyskyday
February 16th, 2004, 18:34
Pardon my confusion, but if you have modules, why are you calling them in iframes and not in a mambo way?

I wouldn't think you could us mambo variables in an iframe page because that is merely being displayed by mambo, not parsed, right? Some expert will be able to explain better...

-Tony

eugsadhu
February 16th, 2004, 18:36
Add the line global $cur_template; to the beginning of your module. Mind you, this would have to be in the module body, and then could be passed as a parameter to the IFRAME page.

eugsadhu
February 16th, 2004, 18:40
Pardon my confusion, but if you have modules, why are you calling them in iframes and not in a mambo way?
If you have a module that needs to update itself (like a hangman game), rather than pull down the entire page again, you could limit the request to the iframe content. Of course, it would probably be much smarter to re-write the hangman code in javascript, flash, or java and then not have to deal with trying to have a php backend process every request.

Digital X
February 16th, 2004, 19:21
thanks for the response guys ..

still no luck .. i put global $cur_template in mod_tagboard.php and mod_hangman.php .. with no reaction in either

limit the request to the iframe content

not realy sure what ya mean there ..

eugsadhu
February 16th, 2004, 19:32
still no luck .. i put global $cur_template in mod_tagboard.php and mod_hangman.php .. with no reaction in either
I am looking at mod_hangman.php:
Change the align=\"center\" src=\"modules/mod_hangman/hangman.php?mosAbsolute_path=$mosAbsolute_path\" line to also pass the template name, i.e. align=\"center\" src=\"modules/mod_hangman/hangman.php?mosAbsolute_path=$mosAbsolute_path&tem plate=$cur_template\"

In mod_hangman/hangman.php, change the global $wordfileName, $wordspage,$mosAbsolute_path, $wordfile; line to include the template's name, as in, global $wordfileName, $wordspage,$mosAbsolute_path, $template, $wordfile; and finally modify the html output of this document to import/use the css. (I leave this as an exercise for the reader.) :)

limit the request to the iframe content
not realy sure what ya mean there ..
That comment wasn't meant for you, but rather for Tony.

Digital X
February 16th, 2004, 20:56
i must say .. it looks great on paper .. i followed your directions to the letter .. but still no luck

all my css is correct .. and works great when i use the actual template name

i.e.
/templates/akodarkgem/css/templates_css.css

i use ..

[code:1:92d92f2764].hangframe
bla : bla
bla : bla[/code:1:92d92f2764]

and call it by

[code:1:92d92f2764]<iframe class=\"hangframe\"[/code:1:92d92f2764]
... works fine


but in its source i was using ..
[code:1:92d92f2764]echo "<link rel=\"stylesheet\" href=\"$mosLiveSite/templates/$cur_template/css/template_css.css\" type=\"text/css\">\n";[/code:1:92d92f2764]
(where "$mosLiveSite" is defined in mod_hangman/config.php)

to call ...
.hangtable

in modules/mod_hangman/hangman.php

[code:1:92d92f2764]print "<table class=\"hangtable\" [/code:1:92d92f2764]


having these types of modules limited to one template_css.css for all templates renders them useless to the multi template user ...

has anyone ever seen a module thats uses an iframe ... like hangman or a tagboard module ... that is able to change the iframes source page css as the templates change ???

thanks again for the help ! :shock: .. lol

eugsadhu
February 16th, 2004, 21:10
having these types of modules limited to one template_css.css for all templates renders them useless to the multi template user ...
So, you want it to import whatever css files are used by the template???
You could always read the css directory of the $cur_template and loop through the .css files, adding the relevant code to the iframe . . .

Digital X
February 16th, 2004, 21:26
So, you want it to import whatever css files are used by the template???

yes .. the "current template"


You could always read the css directory of the $cur_template and loop through the .css files, adding the relevant code to the iframe . . .

sounds great ! .. but im not going to pretend that i know what that means ... lol :lol:

eugsadhu
February 16th, 2004, 21:29
You could always read the css directory of the $cur_template and loop through the .css files, adding the relevant code to the iframe . . .

sounds great ! .. but im not going to pretend that i know what that means ... lol :lol:
This means you open the directory, cycle through all the files in it. For each file you add a link statement to the html document.

I AM OFFLINE NOW, really, I mean it this time. If you haven't figured it out by the time I get up tomorrow morning and check the forum, then I'll try and help more.

Digital X
February 17th, 2004, 07:39
thanks for your help Eugene ..
when you have a chance maybe you could break that last one down in lamens terms for me ... :lol:


For each file you add a link statement to the html document.


??

eugsadhu
February 17th, 2004, 08:15
I haven't tested this code; you may need to modify/edit it.

[code:1:f03b7b5d2c]$template_root_directory="templates/$cur_template";

if ($handle = opendir($template_root_directory . '/css')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<link rel=\"stylesheet\" href=\"$mosLiveSite/templates/$cur_template/css/$file\" type=\"text/css\">\n";
}
}
closedir($handle);
}[/code:1:f03b7b5d2c]

Digital X
February 17th, 2004, 09:14
i tried it a couple of different ways .. get the same return ..

[code:1:646a1b7a4e]Warning: OpenDir: No such file or directory (errno 2) in /home/httpd/vhosts/mysite/httpdocs/rl/modules/mod_hangman/hangman.php[/code:1:646a1b7a4e]

:?

eugsadhu
February 17th, 2004, 09:24
i tried it a couple of different ways .. get the same return ..

[code:1:042255ab6e]Warning: OpenDir: No such file or directory (errno 2) in /home/httpd/vhosts/mysite/httpdocs/rl/modules/mod_hangman/hangman.php[/code:1:042255ab6e]

:?
$template_root_directory="/home/httpd/vhosts/mysite/httpdocs/rl/templates/$cur_template";

Digital X
February 17th, 2004, 09:40
returns the same error ... :cry:

eugsadhu
February 17th, 2004, 09:43
Does the directory even contain a css directory and file?
What is your URL???

Digital X
February 17th, 2004, 10:48
sure does ..

/templates/akodarkgem/css/templates_css.css


i had no idea it could be this complex .. lol


i hate to release a site url in mid construction but if it will help solve this delema .. have at it .. :lol:


http://www.reconlive.com/rl Warning: site is not bandwidth friendly :P and is mostly IE dependant

i have replace the css $cur_template statments with templates/akodarkgem/css/template_css.css ... so you can see the css i want to call with "that template" ... i do not have a template chooser published yet ... but you can see i would want the modules to call the css of my next template and so on ...

eugsadhu
February 17th, 2004, 11:14
According to the URL, you missed the s in templates and also the template= bit.

You have:
http://www.reconlive.com/rl/modules/mod_hangman/hangman.php?mosAbsolute_path=/home/httpd/vhosts/reconlive.com/httpdocs/rl&template/akodarkgem/css/template_css.css
NOT:
http://www.reconlive.com/rl/modules/mod_hangman/hangman.php?mosAbsolute_path=/home/httpd/vhosts/reconlive.com/httpdocs/rl&template=templates/akodarkgem/css/template_css.css
I'm also confused why you have template=templates/akodarkgem/css/template_css.css instead of template=akodarkgem. The other code can't work unless these things are set correctly. Can you post the modifed code somewhere so I can see what changes you have made?

Digital X
February 17th, 2004, 11:40
ok .. fixed that .. lol

didnt want to be one of those guys who post a 3000 px height code .. but ..

.. i figure we have devoted enough time to warrent one ... lol

this works ..
[code:1:8f9683e483]
include_once("config.php");
global $wordfileName, $wordspage, $mosAbsolute_path, $template, $cur_template, $wordfile;


$wordfile=$wordfileName;
//Lets start with opening the file with words
$fp2 = @fopen("$wordfile", 'r');

// and read the words into an array
if($fp2)
{
$words = explode("\n", fread($fp2, filesize("$wordfile")));
fclose($fp2);
}
else
{

die ("Can't find file $wordfile<br />So, I can not form words<br />\n");
}


print "<HTML><HEAD><TITLE>Hangman</TITLE>\n";
print "<meta content=\"text/html; charset=windows-1252\" http-equiv=content-type>\n";
print "<link rel=\"stylesheet\" href=\"$mosLiveSite/templates/akodarkgem/css/template_css.css\" type=\"text/css\">";

include ("$mosLiveSite/noclick.php");

print "<style type=\"text/css\">\n";
print "<!--\n";
print " H1 {font-family: \"Courier New\", Courier, monospace; font-size: 7pt;}\n";
print " P {font-family: Verdana, Arial, sans-serif; font-size: 7pt;}\n";
print " A:link {COLOR: #c0c0c0; TEXT-DECORATION: underline;}\n";
print " A:visited {COLOR: #c0c0c0; TEXT-DECORATION: underline;}\n";
print " A:active {COLOR: #00FF00; TEXT-DECORATION: underline;}\n";
print " A:hover {COLOR: #00FF00; TEXT-DECORATION: underline;}\n";
print "-->\n";
print "</style>\n";
print " </HEAD><BODY bgColor=\"#303030\" background=\"$mosLiveSite/templates/akodarkgem/images/bkg_2.gif\" marginwidth=\"9\" marginheight=\"15\" topmargin=\"15\" leftmargin=\"9\">\n";
[/code:1:8f9683e483]


this does not
[code:1:8f9683e483]include_once("config.php");
global $wordfileName, $wordspage, $mosAbsolute_path, $template, $cur_template, $wordfile;


$wordfile=$wordfileName;
//Lets start with opening the file with words
$fp2 = @fopen("$wordfile", 'r');

// and read the words into an array
if($fp2)
{
$words = explode("\n", fread($fp2, filesize("$wordfile")));
fclose($fp2);
}
else
{

die ("Can't find file $wordfile<br />So, I can not form words<br />\n");
}


print "<HTML><HEAD><TITLE>Hangman</TITLE>\n";
print "<meta content=\"text/html; charset=windows-1252\" http-equiv=content-type>\n";
print "<link rel=\"stylesheet\" href=\"$mosLiveSite/templates/$cur_template/css/template_css.css\" type=\"text/css\">";

include ("$mosLiveSite/noclick.php");

print "<style type=\"text/css\">\n";
print "<!--\n";
print " H1 {font-family: \"Courier New\", Courier, monospace; font-size: 7pt;}\n";
print " P {font-family: Verdana, Arial, sans-serif; font-size: 7pt;}\n";
print " A:link {COLOR: #c0c0c0; TEXT-DECORATION: underline;}\n";
print " A:visited {COLOR: #c0c0c0; TEXT-DECORATION: underline;}\n";
print " A:active {COLOR: #00FF00; TEXT-DECORATION: underline;}\n";
print " A:hover {COLOR: #00FF00; TEXT-DECORATION: underline;}\n";
print "-->\n";
print "</style>\n";
print " </HEAD><BODY bgColor=\"#303030\" background=\"$mosLiveSite/templates/$cur_template/images/bkg_2.gif\" marginwidth=\"9\" marginheight=\"15\" topmargin=\"15\" leftmargin=\"9\">\n";[/code:1:8f9683e483]

this does not work
[code:1:8f9683e483]
include_once("config.php");
global $wordfileName, $wordspage, $mosAbsolute_path, $template, $cur_template, $wordfile;


$wordfile=$wordfileName;
//Lets start with opening the file with words
$fp2 = @fopen("$wordfile", 'r');

// and read the words into an array
if($fp2)
{
$words = explode("\n", fread($fp2, filesize("$wordfile")));
fclose($fp2);
}
else
{

die ("Can't find file $wordfile<br />So, I can not form words<br />\n");
}


print "<HTML><HEAD><TITLE>Hangman</TITLE>\n";
print "<meta content=\"text/html; charset=windows-1252\" http-equiv=content-type>\n";
print "<link rel=\"stylesheet\" href=\"$mosLiveSite/templates/<?php echo $cur_template; ?>/css/template_css.css\" type=\"text/css\">";

include ("$mosLiveSite/noclick.php");

print "<style type=\"text/css\">\n";
print "<!--\n";
print " H1 {font-family: \"Courier New\", Courier, monospace; font-size: 7pt;}\n";
print " P {font-family: Verdana, Arial, sans-serif; font-size: 7pt;}\n";
print " A:link {COLOR: #c0c0c0; TEXT-DECORATION: underline;}\n";
print " A:visited {COLOR: #c0c0c0; TEXT-DECORATION: underline;}\n";
print " A:active {COLOR: #00FF00; TEXT-DECORATION: underline;}\n";
print " A:hover {COLOR: #00FF00; TEXT-DECORATION: underline;}\n";
print "-->\n";
print "</style>\n";
print " </HEAD><BODY bgColor=\"#303030\" background=\"$mosLiveSite/templates/<?php echo $cur_template; ?>/images/bkg_2.gif\" marginwidth=\"9\" marginheight=\"15\" topmargin=\"15\" leftmargin=\"9\">\n";
[/code:1:8f9683e483]

:shock:

Digital X
February 17th, 2004, 11:44
this is mod_hangman.php


[code:1:485cc7e462]<?php
//****Settings****
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
global $cur_template;
$mosAbsolute_path=$mainframe->getCfg( 'absolute_path' );
$wordspage=$mosLiveSite."/modules/mod_hangman/words.html.php";
//************************************************
//********* we start here ************************
//************************************************
//


$my_id = $my->id;
$gid = $my->gid;
$content="";
$content .="<script language = \"JavaScript\">\n";
$content .="function popUp(URL) {\n";
$content .="day = new Date();\n";
$content .="id = day.getTime();\n";
$content .="eval(\"page\" + id + \" = window.open(URL, '\" + id + \"', 'toolbar=0,scrollbars=yes,location=0,statusbar=0,m enubar=0,resizable=0,width=300,height=250,left = 262,top = 184');\");\n";
$content .="}\n";
$content .="</script>";
// $content .=" <table width=100 border=0 bgcolor=\"#FFFFFF\" style=\"border: 0 inset #404040\" >";
$content .="<tr><td><iframe class=\"hangframe\" scrolling=\"no\" name=\"hangman\" frameborder=\"0\" align=\"center\" src=\"modules/mod_hangman/hangman.php?mosAbsolute_path=$mosAbsolute_path&tem plate=templates/$cur_template/css/template_css.css\"></iframe></td></tr>";

if ($gid >= 2) {
$content .="<tr><td><br /><br /><center><A href=\"#\" OnClick=\"popUp('$wordspage')\">administer words</a></center></td></tr>";
}


// $content .="</table>";
?>
[/code:1:485cc7e462]

Digital X
February 17th, 2004, 19:20
anyone else like to take a whack at it ? .. lol


why does this ..
[code:1:21228c493a]
print "</HEAD><BODY background=\"$mosLiveSite/templates/$cur_template/images/bkg_2.gif"
[/code:1:21228c493a]

and this ..
[code:1:21228c493a]
print "</HEAD><BODY background="$mosLiveSite/rl/templates/<?php echo $cur_template;?>/images/bkg_2.gif"
[/code:1:21228c493a]

when viewing the source code in my browser look like this ..
[code:1:21228c493a]print "</HEAD><BODY background="http://www.reconlive.com/rl/templates//images/bkg_2.gif"
[/code:1:21228c493a]

and this ..
[code:1:21228c493a]
print "</HEAD><BODY background="http://www.reconlive.com/rl/templates/<?php echo ;?>/images/bkg_2.gif"
[/code:1:21228c493a]

all the brains in this community must be able to figure this out .. :roll:

eugsadhu
February 17th, 2004, 19:29
anyone else like to take a whack at it ? .. lol


why does this ..
[code:1:df6db46b3c]
print "</HEAD><BODY background=\"$mosLiveSite/templates/$cur_template/images/bkg_2.gif"
[/code:1:df6db46b3c]

and this ..
[code:1:df6db46b3c]
print "</HEAD><BODY background="$mosLiveSite/rl/templates/<?php echo $cur_template;?>/images/bkg_2.gif"
[/code:1:df6db46b3c]

when viewing the source code in my browser look like this ..
[code:1:df6db46b3c]print "</HEAD><BODY background="http://www.reconlive.com/rl/templates//images/bkg_2.gif"
[/code:1:df6db46b3c]

and this ..
[code:1:df6db46b3c]
print "</HEAD><BODY background="http://www.reconlive.com/rl/templates/<?php echo ;?>/images/bkg_2.gif"
[/code:1:df6db46b3c]

all the brains in this community must be able to figure this out .. :roll:

OK, you've confused me again. Why are you putting <?php echo ?> INSIDE of a print? The print should already be inside of <?php ... ?> tags.

Digital X
February 17th, 2004, 19:52
well three reasons actualy .. ignorance , desperation , and this guy suggested it ... lol

http://forum.mamboserver.com/viewtopic.php?t=7345

i obviosly did not give him enough information ...

quite frankly im very new at php and am leaning along the way ...

eugsadhu
February 17th, 2004, 20:11
I am so sorry, as I am no doubt the source of some of your confusion.
I have posted the modified mod_hangman.
http://kizhakethil.net/emambo/temp/mod_hangman.zip

Digital X
February 17th, 2004, 20:56
Ka ChiNG .. lol

it works ...

with one small flaw in the slaw ... source page only calls the css at page load ... and loses it at the point of refresh ..

so loading the definitions at the iframe level is the only way to call the css ?

and the source page will not be parsed at the point of refresh ?


:shock:

eugsadhu
February 17th, 2004, 21:02
You can edit the hangman.php file to add the template code to it.
Edit the line:[code:1:22083466a9]$links .= "\n<A HREF=\"$PHP_SELF?letters=$alpha[$c]$letters&n=$n\" >$alpha[$c]</A> ";[/code:1:22083466a9] and add the template to it.
[code:1:22083466a9]$links .= "\n<A HREF=\"$PHP_SELF?template=$template&letters=$alpha [$c]$letters&n=$n\">$alpha[$c]</A> ";[/code:1:22083466a9]

eugsadhu
February 17th, 2004, 21:04
Also, change the two "Replay" lines to include the template info.
print "<A HREF=$PHP_SELF?template=$template&n=$n>Play again.</A>\n\n";

jomaco1
February 17th, 2004, 21:17
Wow Eugene! An avatar in your honor! Eu-da-man! :P

Digital X
February 17th, 2004, 21:36
Excelent !!

Excelent Work ...

Thank You again for your time and patience ... this has been a great tutorial ..

now im going to see if i can apply these principals to the cj tagboard module

:D

Mambo On Friend ...

eugsadhu
February 18th, 2004, 06:45
Wow Eugene! An avatar in your honor! Eu-da-man! :P
Wow, I hadn't even noticed the avatar. Thanks, Digital X :oops: