Hi! I'm working on my first processwire project and everything is working ok, but i have a question stuck in mi head: which is the "best" way to organize functions and stuff on php/processwire (is my first php project too). I have something like this:
-- functions.inc
-- home.php
-- foo.php
-- bar.php
functions.inc have all the "get" functions that pull out content of the database, like: function getHomeNews($posts){
$out = array;
foreach($posts as $post){
$out["name"] = $post->title;
}
return $out;
}
then in my home.php template i put a "render" function and do the echo thing to show the html on the front end: function renderHomeNews($posts){
foreach($posts as $post){
$name = $post{name};
$out = "<h1>{$name}</h1>"
}
}
$news = $pages->find("template=news");
echo renderHomeNews($news);
Suddenly a question comes to my mind, what if i put all the "render functions" of the project on renders.inc and all the "getter functions" on getters.inc, so the code on the template could be smaller and all the functions will be on just two files. That makes sense? is the same stupid thing? How do you organize your projects? Thanks!