Views preprocessors in module files

0 Comments

We've all used pre-processors to modify data before it reaches the template file to be printed. These pre-processors are usually defined in template.php with a corresponding template file within the themes folder. The views module is quite helpful because it allows others to use their own themeing files to design their own views.

I was working on a custom node module and wanted to implement views hooks, so that I can expose my tables data to views, and to create default views. Exposing the extra data from my table was relatively simple as I simply implemented the hook: hook_views_data. With this hook, I was able to setup my fields, filters, arguments, and sorting.

So now, with my exposed data ready to be used, I was ready to implement hook_views_default_views. I initially created the views through the user interface and then pasted the exported code in my hook_views_default_views implementation.

Changing Primary Domain in Domain Access Settings

0 Comments

Changing the primary domain once it has been set in the Domain Access settings can be quite the challenge. I encountered a problem, which required me to change the primary domain to one of the active domains. This would have been easier if there were no nodes associated with the domains and if the project was in its early development stage. However, this wasn't the case. I had no choice but to write a script that would do a simple swap algorithm, which would switch the current primary domain's settings with the new primary domain (an active domain).

Keep in mind that by the architectural design, the primary domain will always have an ID of “0”. The rest of the domains' ID will start with “1” and so on. For the purpose of this blog, let’s assume that the old primary domain is a.com and the new primary domain is z.com.

Here are the following steps I took in order to accomplish this task:

1) Switch the domain configurations of a.com and z.com.
To accomplish set some system variables for z.com:
“domain_root,” “domain_sitename,” “theme_default, “site_frontpage,” “site_name,” “site_offline_message.”
Then update the configuration of a.com in the domain_conf table.