Getting currently selected theme from a Block Controller or View

Permalink
Hi, I am working on a few blocks and I needed to read some data from a XML file that I have in my currently selected theme. Of course I can hard code this path in, and I guess I could parse the directory and put in a drop-down box of the theme that is currently being used, but this would require user intervention.

I am basically trying to make sure that none of the images of a theme I throw in on a site install break the layout and I am using the new libraryblockcontroller function to facilitate this. I can see other uses for something like this way down the line.

So I just need to figure out how to get the block to be aware of which theme is currently being used (If it isn't already) and the path to that theme.

Any help would be greatly appreciated.

Thanks :)

-Scott

ScottC
 
Remo replied on at Permalink Reply
Remo
UPDATE: It's part of view.php in libraries but I couldn't find anything about this file in the API doc..

I'm not sure where this function is available. But I was able to get the path using

$this->getThemePath()


I tried to find this method in the api documentation but couldn't find it.. google also did not want to help me with that.
ScottC replied on at Permalink Reply
ScottC
The Image block, I am not sure if this would be considered a core block as I have noticed some reference to core blocks, but I believe that is in the controller for the dashboard.

When I add your code to my block's view.php (which i guess it can exist there, rather it be in the block controller), I get nothing at all. Oddly enough though, when I am on the index or home page, it actually says that the path is "Home Page". Any page other than this doesn't output anything.

The theme path I am looking for is a custom template that would reside inwww.www.remo.com/themes/remo/data.xml,... and I need the instance of the block via the controller or the view to know in which theme it will be rendered before it is rendered, if that makes sense.

-Scott
Remo replied on at Permalink Reply
Remo
as mentioned on irc.

getCollectionThemeObject is part of the Page class. Be careful when getting the Page object, read this first:http://www.concrete5.org/community/forums/customizing_c5/block-getb...
ScottC replied on at Permalink Reply
ScottC
I get an array that shows up that looks like this:

http://pastie.org/334325

And the ptURL is exactly what I need. I noticed that there was another function under PageType::getThemeURL but I haven't been able to get this to work either.

Any guidance would be appreciated.

Thank you.
Tony replied on at Permalink Reply
Tony
<?
$v = View::getInstance();
//url
echo $v->getThemePath().'<Br>';
//directory
echo $v->getThemeDirectory().'<Br>';
?>
ScottC replied on at Permalink Reply
ScottC
works, didn't think to get a copy of the instance, tried a bunch of things :)

Thanks Tony and frz.