Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
898 views
in Themes by

I am running a brother site of my main site. To reduce administration I am using for both the same plugins and themes.

For the theme options, I needed different colors (was able to do specific options by SCSS includes) and logos. Easy.

But when it comes to the qa-theme.php I am a bit stuck.

It seems that I cannot include('custom-file.php'); in the class qa_html_theme extends qa_html_theme_base {...} to access those variables (options) globally.

It seems that I can do so only in the functions(), which requires several includes of several files.

Is there any other option?

PS: Unfortunately, there is no way to define "custom fields" for the theme. And I do not want to create a separate plugin for each theme. It just doesnt feel right.

Q2A version: 1.8.0

1 Answer

+1 vote
by

If you don't want to change the code, then you have to store the changes in the database. This makes a lot of sense because you have exactly the same code in many sites, each with its own configuration.

The second approach for not having to modify a plugin, theme or core files would be to set some constants in the qa_config.php file. That file is intended to have different configurations in a per-site basis so it is not a big deal to have some extra stuff in there and it will survive Q2A upgrades.

by
Nice tip with the qa_config.php.

I would like to store custom variable in the theme, and could use qa_opt('mytoken'); but there is no "interface" how to modify them. The editing should be done in phpmyadmin, I guess. This is why I asked for a backend control of flexible admin options. http://www.question2answer.org/qa/62103/
by
If you're using qa_opt() then it is not stored in the theme but rather in the database. Accessing qa_opt() from the theme itself is perfectly feasible.

You can also use the theme to add new sub-sections to the admin section with all the theme configuration. It will look a bit messy, though.

Considering theme setup is something that is done only one time and should take a considerably small amount of time I wouldn't care at all about using an SQL client to update a few settings (in particular a "token" which change so infrequently, if they actually do!).
by
I ended up writing my own plugin - only for the options, it's just more convenient. But hope that Scott will add some new "theme options feature" to the admin backend, that can be defined in qa-theme.php
by
That should be the most appropriate approach if you REALLY need the UI. I didn't mention it because you explicitly said "I do not want to create a separate plugin" :)
by
"the most appropriate approach" with q2a v1.8.0 and prior. Maybe in 1.9 it's not necessary anymore :) ...
...