Jump to content

Update 'getTemplate' function


Wolfie

Recommended Posts

Currently if a template is called on that doesn't exist in the skin set being used, an error is returned. Could that be updated to return a '' (nothing) if it doesn't exist? Either that or change it so that if a second parameter is passed, it'll instead return a boolean of true/false for if the skinbit exists.

Pretty much doing this, but as an included function:

method_exists( $this->registry->output->getTemplate('global'), 'globalTemplate' )

So that it could be called using this:

$this->registry->output->getTemplate( 'global', 'globalTemplate' )



The if someone wants to make sure a particular template/bit exists before calling it, perhaps to prevent an error from occuring if it doesn't, then they could.

Link to comment
Share on other sites


Currently if a template is called on that doesn't exist in the skin set being used, an error is returned. Could that be updated to return a '' (nothing) if it doesn't exist? Either that or change it so that if a second parameter is passed, it'll instead return a boolean of true/false for if the skinbit exists.



Pretty much doing this, but as an included function:


method_exists( $this->registry->output->getTemplate('global'), 'globalTemplate' )

So that it could be called using this:

$this->registry->output->getTemplate( 'global', 'globalTemplate' )



The if someone wants to make sure a particular template/bit exists before calling it, perhaps to prevent an error from occuring if it doesn't, then they could.


I'm all for this.
Benefits would be immense, especially when developing hooks with ACP added Templates that don't exist on non-master skins.... much less the avoidance utterly of the IP.Content 3.1.4->3.2.x Fiasco Re-occurring in Future versions({parse template="user_popup"}==fail)
Link to comment
Share on other sites

Re-reading it, I may have babbled an incomplete thought.

The current structure would still work as-is, just that if the 'function' is included as a second parameter instead of added onto the end, then getTemplate would return a boolean true/false instead of attempting to return the skin file/function.

Example:


if ( $this->registry->output->getTemplate( 'global', 'globalTemplate' ) )

{

  $output = $this->registry->output->getTemplate( 'global' )->globalTemplate( parms, parms, parms, etc );

}


The first use would be the new use. The idea is to not only provide an easy to check if it exists for trying to prevent errors, but also to add functionality. For instance, let's say that an app will make use of a certain skin bit if it's available. It checks and if it's not, then it skips past it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
×
×
  • Create New...