Using the Course/User Theme Problem

Using the Course/User Theme Problem

by Jeffery Watkins -
Number of replies: 8
Ray Lawrence pointed this out to me, and I thought it was a problem with my themes, but I just tried one of Himmat's 1.5 themes and the problem persists.

Problem:

If site is using Theme A, and a teacher sets their course to Theme B, Theme B's header graphics will not show.  The source code has all of the tags for Theme B's header graphics, but it is looking for them in Theme A's folder.

Now, this could very well be a problem of the themes Himmat and I have created, as we do similar things, but it might also be a Moodle problem which is why I mention it.

Thanks for any help on this from the higher ups.

Jeff
Average of ratings: -
In reply to Jeffery Watkins

Re: Using the Course/User Theme Problem

by Urs Hunkler -
Picture of Core developers

Hi Jeff,

it could be that you stumbled over the same point as I did.
Please look at my forum post "Linking to the current theme".

I hope you get it that way.
Urs

In reply to Urs Hunkler

Re: Using the Course/User Theme Problem

by Jeffery Watkins -
Thanks Urs, that did the trick.

When using graphics in the header, I was using this format:

<?php echo "$CFG->wwwroot/theme/$CFG->theme/image.jpg" ?>

switched to this as suggested by Urs:

<?php echo $CFG->wwwroot.'/theme/'.current_theme() ?>/image.jpg ?>

and everything works fine.

Jeff
In reply to Jeffery Watkins

Re: Using the Course/User Theme Problem

by David Banach -
I had the same trouble with the Romanmoodle15 theme from Moodle Themes and fixed it via your suggestion replacing all instances of
<?php echo "$CFG->wwwroot/theme/$CFG->theme" ?>
with
<?php echo $CFG->wwwroot.'/theme/'.current_theme() ?>
in the header.html file of the theme


Thanks for the suggestion. This was driving me crazy!
In reply to Jeffery Watkins

Re: Using the Course/User Theme Problem

by Adele Thomas -

Thanks, this solution worked for me, too! It seems that the quotations around '/theme/' made the difference! Why is adding graphics to headers so difficult? smile

Here's a link in case you need it! http://moodle.org/mod/forum/more info/discuss.php?d=24190

Thanks again!
Adele

In reply to Adele Thomas

Re: Using the Course/User Theme Problem

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

<?php echo "$CFG->wwwroot/theme/$CFG->theme/image.jpg" ?>

switched to this as suggested by Urs:

<?php echo $CFG->wwwroot.'/theme/'.current_theme() ?>/image.jpg ?>

It's because the line is written in php as an echo, Adele.

In the first line <?php echo "$CFG->wwwroot/theme/$CFG->theme/image.jpg" ?> the line is going to echo everything inside the ""

In the second line <?php echo $CFG->wwwroot.'/theme/'.current_theme() ?>/image.jpg ?> the echo command first takes whatever comes out of $CFG->wwwroot, then the . tells the echo command to concatenate it (add it to) whatever comes next, in this case the bit inside the ' ' /theme/ followed by another . to add it to the next part which calls the name of the current theme being used current_theme()

Just for neatness sake I would probably have added the final /image.jpg inside the echo as well giving you

<?php echo $CFG->wwwroot.'/theme/'.current_theme().'/image.jpg' ?>

All this seems to add additional complexity to what should be a straightforward <img> link, but it allows the theme to be renamed (current_theme()) or used on different server setups ($CFG->wwwroot) without having to recode the theme each time.

It does take some getting used to when you start looking at themes, but its well worth getting to know smile

Hope that explanation helps a bit

Richard

In reply to Adele Thomas

Re: Using the Course/User Theme Problem

by Mary Evans -

It's not as simple as adding quotations around '/theme/' in the example you linked to, there are other factors at play too.

Here's a link in case you need it! smile

Mary

In reply to Jeffery Watkins

Re: Using the Course/User Theme Problem

by Karim Assy -

Dear sir,

im having a problem with the them i guess nearly the same ive upload a theme and its showing the header and footer but the middle pic and the remain inside nothing plz can u help me to solve it thanks check the site www.websedu.com it as also inside a background and everything none of them are showing only the header and footer and the footer has enlarged