2

I am searching for opinions about the construction of static pages in Drupal.

Imagine this page as a PSD or PNG: https://www.paypal.com/br/webapps/mpp/quanto-custa-empresa

It's a static page, but it's not just text, it has a somewhat rich layout. I don't think a regular node with WYSIWYG is the right way to do a page like this.

So, imagine you already have the template built, the side menu, the header, footer, etc, but you want more control over the content (middle) layout.

These are the ways I know for building this kind of "rich content":


Create the HTML page in a decent editor, then paste the HTML on the node body when you're finished.

Pros:

  • Practical for extremely simple pages

Cons:

  • Lose version control
  • If you do node-specific CSS, which is pretty much necessary for this kind of page, you might get into trouble if you can't maintain the node id between installations
  • Needs php input format in order to print images relatively
  • Requires back and forth from IDE every time something changes

Node-[id].tpl.php template

Pros:

  • Version control
  • Allows you to keep working on the IDE

Cons:

  • When doing node-specific CSS, which is pretty much necessary for this kind of page, you might get into trouble if you don't have a way to maintain the node id between installations
  • Same thing for the whole page. It will go blank if you don't keep track of the node ID.

hook_menu + hook_theme invoking a custom template for the wanted path

Pros:

  • Version control
  • Allows you to keep working on the IDE

Cons:

  • Requires custom module and a little more effort
  • Does not provide caching by default like a node does (performance hit wouldn't be that great for this, however)
  • You lose some node juicy stuff (can't remember an example right now)

So, are there any methods people are using I'm not aware of? Maybe with panels? Context? Please let me know!

0

If this is a one off landing page, I'd go with option 1.

I would never do 2 because I also deal with different installs (dev/stage/prod) and that would break on me.

For option 3 I usually use a different flag in the data other than URL, but I've occasionally used this method. Usually I have a 'Use Template' field that points at a taxonomy, and I can make various theming decisions off of that (including but not limited to the tpl I use)

If this is a layout you think you'll see again, I'd use Panels. Especially if you want this to be editable by people who don't know code.

You can specify very generic to very complex layouts. You basically specify a layout in a tpl file with regions that can get content added to them. The content can be nodes, blocks, views whatevs.

It has a bit of a learning curve on the dev and the content editor side, but it's pretty good.

With your node specific CSS, I would recommend adding a "Custom CSS" field to content types that are going to have special layouts. You could do this to what I call a "Custom Page" content type which I use to simply paste in HTML, or add it to Panel Nodes or other customizable node types.

In the theme you'll need to hide($content['field_custom_css']); in the node preprocessor and then retrieve the value of the field and run drupal_add_css() on the sucker.

You can use file field to allow people to upload CSS, or what I do is specify the URL of the file so I can just re-up the file while I'm working with FTP and don't have to re-up through the drupal interface every time I have a change.

By default drupal_add_css doesn't let you add CSS files that aren't on your domain so if you make the user specify a URL (meaning they'd have to have FTP access to get something in there) it's a fairly secure implementation.

Pretty sure there's a way to allow css that's not on your domain, but you'd want to make sure that nefarious parties aren't able to do damage with that field if you decide to go that route.

Custom CSS has been HUGE in doing one off pages like this for all of the promotional pages my group does at work.

Hope that helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.