ZenphotoCMS Forum
[Code] Echo in Theme Functions - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: [Code] Echo in Theme Functions (/thread-5018.html)



[Code] Echo in Theme Functions - DarK - 11-04-2009

I am currently adapting zenPhoto to integrate into an existing website; however I am been royally hindered by the current template functions in zenPhoto.

I currently can not use a function without the fear of a direct echo been used and totally screwing up placement within the current page.

As a matter of personal preference I believe using echo in external functions is bad practice and it leads to this kind of headache when performing integration.

Please consider buffering function output and using return.

Cheers

DarK




[Code] Echo in Theme Functions - acrylian - 11-04-2009

I recommend to take a closer look at our functions guide then you will notice that a "get" variant exists for nearly every "print" function.




[Code] Echo in Theme Functions - DarK - 13-04-2009

Thanks very much, this will help.

Again though why the need for both get and print?

If you use a get function with a return to an echo in a template, is this practically the same as what a print function does?

Is this not code duplication?

Cheers

DarK




[Code] Echo in Theme Functions - acrylian - 13-04-2009

Yes, the simple print function like with printImageTitle() for example is mostly actually just a echo getImageTitle() but that is not all it also contains the inline editing support. Take a look at template-functions.php for details.

There are also some functions that really yneed to echo something as they do some more complicated things than just return one thing (like printAllTagsAs, the nested printAlbumMenu()plugin among others).

Also, you will maybe agree that a is a little more direct and shorter (and less cluttered looking) on the theme side than, especially for not used tophp users.