I have a project where several sites pull their content from the same database. It allows me to govern the site content for all the sites in one place no matter where I am.
The database has a list of the sites and the settings for each site. Each site has several templates unique for that site but all the sites share the same set of variables (code, name, description, search box settings, which ads to show, etc.). While the values may be the same, the variable set is the same for all the sites. There are probably around 40 variables and a large number of them are used on most pages of each site.
When a user visits a page, the code queries the database for the correct information to display on the page. It first gets the site settings, then it gets the settings for the page (including which template is used for that page), and then it runs a series of functions to retrieve the data that is displayed in the template.
Because the site settings are used repeatedly, I created one array that holds all the variables.
$arMyVars['var1name'] = 'sitecode';
$arMyVars['var2name'] = 'ad type to show';
$arMyVars['var3name'] = 'header picture';
$arMyVars['var4name'] = 'template to use';
... and so on.
For the functions, I simply pass the one array and any of the variables that are needed are available to the function.
Is there a better or more efficient way of doing this?
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.
Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/