Finishing the Installation Profile

We're down to the last section of the philosopherbios_profile_tasks() section. We have looked at how the submission handler set the default theme as a result of the call to drupal_get_form() below. Let's continue looking at the philosopherbios_profile_tasks() function to see what happens after the form data has been processed:

$form = drupal_get_form('philosopherbios_theme_form', $url); // See if the form was processed:

if (variable_get('philosopherbios_theme', FALSE)) { variable_del('philosopherbios_theme'); $task = 'profile-finished'; } else {

After the drupal_get_form () call, what we need to find out for sure is if the submission handler was really called. In other words, we want to make sure that the user really did progress through the theme-picking screen. We can tell by checking to see whether or not the variable philosopherbios_theme is set in the variables table.

Recall that we used variable_set() at the beginning of philosopherbios_theme_ form_submit(). So here we can tell whether the submission handler was run based on the presence of that variable.

If variable_get('philosopherbios_theme', FALSE) returns FALSE, then we know that the submit function was not run. The else block is executed, sending the form back to the user.

But if the call to variable_get('philosopherbios_theme', FALSE) returns TRUE, we know the submission handler was run. We just need to clean up and return control to the installer.

For our installation profile, cleaning up is pretty simple. We've only left one variable in the variable table. We delete it with variable_del():


To return control to the installer, we need only inform it that the profile tasks are all finished. That is done by setting $task to profile-finished and allowing the function to return.

Taking a look back at the installer, the user chooses a theme and then clicks Save and continue.

Default Theme:

Descartes f* Garland

Set the default site theme.

Save and continue |

The form is processed; the theme is enabled, initialized, and set as default; extra data is removed; and control is returned to the installer. From here, the install will proceed on to the final screen of the installation process:

Philosopher Bios Profile installation complete

Congratulations, Philosopher Bios Profile has been successfully installed.

That is all! If we were to go into the new site and look around, we would find all our content types (Quote, Biography, News Brief) available in Create content. The trigger would be activated for news brief publishing. The philquotes and goodreads blocks would be available for configuration on the Administer | Site building | Blocks page. Our user profiles will all have the option for administrators to send an email, as provided by the emailusers module.

Want to préconfiguré your blocks?

With a little more work, the installation profile could add our philquotes and goodreads blocks to the default theme. This requires doing some low-level work on the blocks tables. A good place to start is in modules/block/, specifically with the block_admin_configure_submit() function. m

Now we have configured our custom distribution. All we need to do is package it.

Was this article helpful?

0 0
Article Marketing Gold

Article Marketing Gold

Discover How You Can Use The Huge Power of Article Marketing To Drive Highly Targeted Traffic To Your Website and Instantly Become THE Person Your Prospects Want To Buy From.

Get My Free Ebook

Post a comment