Need help with GetThemeDirectory inside Block

Permalink
Hi everyone,

I'm trying to create a small block for my website to let me specify a file listed under ELEMENTS folder from the Active theme.

A simple Listbox displaying all the file from that folder. Selection is returned to output into a include:
<?php 
$this->inc('elements/[filename selected]'); 
?>



Here is my script from my form_setup_html.php

<select name="php_includes_file" value="">
   <?php
   $dirpath = $userview->getThemeDirectory();
   $userview = View::getInstance();
   if ($handle = opendir($dirpath.'/elements/')) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != "..") {
           echo "<option value=\"\">".$file."</option>\n";
       }
   }
   closedir($handle);
   }
   ?>
</select>


I can't get the ThemeDirectory path, it always return empty.

Thanks

olacom
 
ScottC replied on at Permalink Reply
ScottC
$dirpath = $userview->getThemeDirectory();
$userview = View::getInstance();

flip those around. If you aren't omitting code you're calling a function on an empty object.



another one is $this->getThemePath(); i believe?

or $userview->getThemePath()?