Displaying a Drupal page on another website

Question:

We need to display a Drupal page on another website. Is there a way to have Drupal render a page without the site’s layout around it?

Answer:

Yes that is possible. Assuming the other website was developed using Drupal 7. If yes, by adding some scripts in the template.php, which resides under the website’s theme folder, we can achieve it. ??

Suppose, you want to display the particular CMS node page to be displayed without the default template design. For example, the node id is “6”. ??

Step 1: Create a file named “page–display.php” and remove all the scripts except this line “”??

Step 2: Add a function in the template.php as below. If this function already exists, just add the conditional if statement only in that function.

Else, place the entire function in the template.php file. Here, the function name “bartik_preprocess_page” is an hook. So in standard it will be like “yourtemplatename_preprocess_page”. Replace the “yourtemplatename” with the installed template name. ??

Here, we have used the default theme name “bartik”
for example. So the script will be like the below. ??


functionbartik_preprocess_page(&$variables) {?
if(arg(0)=='node' &&arg(1)=='6'){?
$variables['theme_hook_suggestions'][] = 'page__display'; //
represent the hyphen as underscore lines. ? }?}

This entry was posted in Drupal Developer Notes. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *