Jump to content

gumbygreen123

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

gumbygreen123's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, so a couple days later and it seems that the partial path is the same as the layout path. There is probably a way to add additional layout paths but I don't really want to do that. The reason why I asked this question in the first place was to see if I could place general layouts in one folder and sub layouts in the same folders and locations as normal view script files. That way I could still utilize those script files that didn't seem to be doing anything after I discovered Zend_Layout. So, now I've decided to place the layout files directly in the 'scripts' folder and from there call the various scripts as partials to that layout. In the master layout I call the partials automatically with a string generated in the controller. In the controller I create an action helper that parses the URI and uses that information to determine the content partial that should be called. Below is the action helper (I'm not great with regex so there is a better way to do this and there is probably a better way to do this anyway using the Zend_Framework URI parser. Any insights on this would be helpful!): class Action_Helper_PartialEngine extends Zend_Controller_Action_Helper_Abstract { public function direct() { // Parse the uri to determine the current page. $pieces = explode('/',$_SERVER['REQUEST_URI']); // Determine the folder. $folder = ($pieces[1]) ? $pieces[1].'/': 'index/'; // Determine the file. // If the second piece has a dash in it, remove the dash and capitalize the first letter after the dash. if($pieces[2]){ $morePieces = explode('-',$pieces[2]); $i = 1; foreach($morePieces as $piece){ $file .= ($i > 1) ? ucfirst($piece): $piece; $i++; } $file .= '.phtml'; }else{ $file = 'index.phtml'; } // Return the correct path. return $folder.$file; } } Then in my controller I add the following code: class IndexController extends Zend_Controller_Action { public function init() { $this->view->partialName = $this->_helper->partialEngine(); } ... (actions etc.) } ...And in the master layout, where I want to call the partial I add this code: <?php echo $this->partial($this->partialName,$this->partialArray); ?> Any other insights on this would be helpful.. What do you all do?
  2. As I've been using view partials I've realized that partials can only be used in the same (or perhaps a sub directory) directory that the script or layout is being read from. Is there a way to change the partial directory in Zend Framework? Thanks!
  3. .... and, I might add, I have a hard time learning. (I'm probably just a little thicker than most)
  4. I've been studying Zend Framework a lot lately as our company is moving to using that more. I think I own or have read every book on the subject and have read some tutorials. The best book I've found to get started is 'Beginning Zend Framework' by Armando Padilla. (no, I'm not Armando and have no affiliation with him). I haven't really found a tutorial worth getting started with. I haven't figured out why but Zend Framework seems to be something that teachers have hard time teaching.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.