Requiring a php-script with custom functions before any block-call

Permalink
So I've installed ProBlog and I'm customizing it to do some fancy tricks, displaying colors for each category etc. But I've run into an issue I don't know how to fix.

I have a php script located in the following folder:
themes/[my-theme]/php/functions.php

Every file in my theme-folder that concrete passes through, such as default.php; view.php; custom page-types - calls the file functions.php that retrieves attributes from specific site-sections and that has helpful functions that I use to style the site.

But for some reason when I edit a page that was created with pro-blog, I get an error that one of my functions wasn't found:
Call to undefined function getSomeStuff() in /[root]/packages/problog/blocks/content/templates/blog_post/view.php on line XX

(note: yes, I customized that pro-blog file)

This tells me that my script-file wasn't loaded at the time that the pro_blog-block created the html-content. The rest of the site is displaying fine and it did go through view.php in the theme root folder which references my function.php, just not before creating the pro_blog-content but after creating it...

So my question, is there a way to use my custom functions everywhere by including it before concrete uses any of the blocks to process (render) html?

thanks very much!

yoschi
View Replies: View Best Answer
yoschi replied on at Permalink Reply
yoschi
I haven't really gotten any further on this, any tips?
yoschi replied on at Permalink Reply
yoschi
anyone?...
12345j replied on at Permalink Best Answer Reply
12345j
i'd just load in in dispatcher.php
yoschi replied on at Permalink Reply
yoschi
Thanks for your answer.
I had tried the dispatcher before but couldn't get it to work properly, but now I know why.
I had put my include after this line:
require(dirname(__FILE__) . '/startup/tools.php');


now I added my functions before the tools call and it's working. Better yet, there is a call to a file called "site_theme_paths.php"
## Specific site routes for various content items (if they exist) ##
if (file_exists(DIR_CONFIG_SITE . '/site_theme_paths.php')) {
   @include(DIR_CONFIG_SITE . '/site_theme_paths.php');
}

which points to that file inside the root /config foder. I just added my include call into that file:
include(DIR_BASE . '/themes/[my-theme]/php/functions.php');

Now, even if I update concrete5 it still works since I didn't have to touch dispatcher.php! :D

of course, site_theme_paths.php was meant to be used to override system layouts, but in this case it suits my purpose ^^