Dynamic landing pages
The following post will cover how to create dynamic landing pages. First lets define our mission:
Allow easily creating landing pages, with different content. The layout should be a header and footer which are always the same, and the main-content should be three columns layout, with dynamic content.

Before we go too technical, let's translate the task into plain English in order to solve our task.
The layout should be a header and footer which are always the same
Or we can say it differently - don't show the sidebars. A quick and dirty way of doing it, will be overriding page.tpl and remove the printing of the sidebars.
...three columns layout...
That's easy with Panel's three column layout (or we can create our own layout using 960).
...with dynamic content.
Dynamic content - that sounds like a job for Views. We can have a content type, that will have cck fields that describe the location of it (e.g. left, middle), and the page it should appear (e.g. /landing-page/foo). Views will get the right nodes for us.
Ok, now we know how we want to implement it, let's get our hands dirty (or download the example module, and skip to 7).
- Download and enable necessary modules:
drush dl cck views ctools panels
drush en optionwidgets text views_ui ctools _panels page_manager views_content - Starting from the lowest level, we'll create a new content type called "Landing page element" with CCK fields - select list for the "Location" and a textfield for the "Page ID"
- Create a View that shows the full nodes, filtered by node type, that gets two arguments - the "Location" and the "Page ID"
- Add a new display of "Content pane" type. This display type is what ties Views to Panels in a way that allows us to define how the View is going to get its arguments
- Set the Page ID argument to be taken from the panel argument - or in other words, if the url will be landing-page/foo then foo is our page ID. The Location argument, on the other hand, shouldn't be taken from the URL - it should be set in the Pane configuration

- Create a panel page in the path
landing-pagewith a three column layout, and in the content add our view to each of the columns. Every time the "Location" argument will change according to the column the View is added to


- Next, in our theme to copy page.tpl.php to page-landing-page.tpl.php, and the printing of the sidebars
- Optional; copy node.tpl.php to node-view-landing_page.tpl.php and delete the printing of the node title
- Optional; In admin/build/themes/settings uncheck "Display post information" from our new content type
- Now, all that is left to do, is to add three Landing page elements content, with the same page ID (e.g.
gizra), and with different locations - Navigate to landing-pages/gizra and see your landing page!
Another small note about using Panels, Views and nodes together. Although Panels allows us to add an existing content, I normally prefer to use a View that will return that node. Why? Because most of the sites I work on are multilangual, and if I hardcode the node ID then the users might see a node in the wrong language. View on the other hand can make sure the node the users see is in their language.

תגובות
Weborms
Naturally, if you want to add a form/ webform you can do it via the Panels page.But to make it dynamic you can add the "Page ID"/ "Location" to your webform content type, and change the View's filter to include webform as-well.
What is the page id refer to
What is the page id refer to ? the node id or path alias of another content to display ?
@Adrian, The page ID is any
@Adrian,
The page ID is any text you want to use. It can be a for example a campaign you are running (e.g. "april-2010-deal" and another would be "march-2010-deal-for-us-only".
Great stuff... tweek and suggestions
This is a great tip. This is much better than the way I was doing landing pages. I doing lots of different types of marketing and this is great for quick and easy landing pages (for adwords for example).
One tweak I made was to allow the content to have multiple pageid's. That way you can reuse your content for multiple landing pages (like an image or lead capturing form).
Also, I would add use pathauto to make the path of the "landing page element" something like "mysite.com/lp-element/elementnode" and add
/lp-element/to my directories section of my robots.txt. That way your landing pages aren't seen as duplicate content of your element nodes by the search engines.Also, instead of doing the theme stuff, couldn't you just change your view up so it only shows the node body... not the full node? That would also get rid of the "display post information" stuff.
Great stuff I like this idea.
> Also, instead of doing the
> Also, instead of doing the theme stuff, couldn't you just change your view up so it only shows the node
A node can have other fields attached to it, and sometimes your want your Views to be ignorant about the fields. Anyway, you are right, there are some tweaks you can have -- the post here tried to keep things simple.
Also, if you keep a single page ID, you can later have a rule that will redirect users to the landing page, if they try to view a "landing page element" node.
I'm happy you liked it :)
Useful for dynamic image banners
This really got me thinking about how this could be used for image banners.
A great solution to this problem is to use http://drupal.org/project/headerimage
But, I was hoping to replace this module with views and the technique you mentioned.
Headerimage allows you to create dynamic blocks that you can assign nodes to.
Headerimage allows you to specify the visibility settings for each node and choose which block the node is assigned to.
This article allows you to do something similar like specify the paths(page-ids) that the node should appear on but doesn't quite cover the cases like show on /2007/*
Oh well, back to the drawing board. Thanks for the article.
פרסום תגובה חדשה