I have several pages with unique layouts from the designer. All share a common footer/header but in some there are 2 columns in others 3 columns. Some have boxes with text others have no boxes--in short, there are almost 10 different unique layouts.
I can build each one with HTML no problem, but they want certain pages to be easily editable by non-technical personnel--they want to be able to edit each item as pure text. So my inclination is to separate these pages into separate areas and make each one a node of some sort.
The first idea that comes to mind (for a page with 3 boxes, for example) is to make 3 nodes, one for each, and then enter the content. Then I make a page and use PHP to put the content of each into the correct <div>.
Then the users can edit the content nodes and not the page nodes.
Questions are: Is this a reasonable approach? Is there a better one? Should I use a CCK node for the boxes or would a 'page' be enough? I would think that if I only need body and maybe title, that page should be enough.
Thanks!
PS: I considered using tinymce or some such and building the pages that way, each as one page, but the HTML is generally ugly then and also it makes me nervous that it's easy for a user to break a page that way, because he has control over the layout, yet doesn't know what he's doing...
On Wednesday 19 September 2007 07:30:31 Fred Jones wrote:
I have several pages with unique layouts from the designer. All share a common footer/header but in some there are 2 columns in others 3 columns. Some have boxes with text others have no boxes--in short, there are almost 10 different unique layouts.
I can build each one with HTML no problem, but they want certain pages to be easily editable by non-technical personnel--they want to be able to edit each item as pure text. So my inclination is to separate these pages into separate areas and make each one a node of some sort.
The first idea that comes to mind (for a page with 3 boxes, for example) is to make 3 nodes, one for each, and then enter the content. Then I make a page and use PHP to put the content of each into the correct <div>.
Make each box (not the pages) a separate node with it's own content.
Then the users can edit the content nodes and not the page nodes.
Questions are: Is this a reasonable approach? Is there a better one? Should I use a CCK node for the boxes or would a 'page' be enough? I would think that if I only need body and maybe title, that page should be enough.
Try checking out the Panels module: http://drupal.org/project/panels
Thanks!
PS: I considered using tinymce or some such and building the pages that way, each as one page, but the HTML is generally ugly then and also it makes me nervous that it's easy for a user to break a page that way, because he has control over the layout, yet doesn't know what he's doing...
Um, I'm not even sure that's possible.
Make each box (not the pages) a separate node with it's own content.
Yes, each box is a node and then the actual page is a page which includes the content of those nodes.
Try checking out the Panels module: http://drupal.org/project/panels
Very interesting. This is actually exactly what I proposed, but it's all setup for me already. :)
OK, I will try with this. It may be easier for me to do this manually, but we will see. :)
Thank you very much!
Fred
Make each box (not the pages) a separate node with it's own content.
I am using this approach and it's 95% done. I made a new content type, let's call it box and then I made a page. The page is PHP code which fetches the correct box nodes from the DB and displays them.
The page in question is setup like a FAQ where at the top are the questions, each with a link to the answer. The answers are on the same page. I thus loop through the result set twice, once to generate the links and once to generate the answers. OK, I could store the answers in a variable in the first loop and print at the end, agreed.
My question is, however, regarding the body text of my box nodes. I am fetching it thusly:
$result5 = db_query("SELECT body from node_revisions where nid = ".$row->nid.";");
which works, but it returns the raw text, without the <p> tags added. Is there a Drupal function that will add them in for me?
I thought about using contemplate for this, but I don't know how I could do it because I need to loop through the result set twice, or at the least, present the data twice.
Any ideas are appreciated. :)
Thanks.
On 9/19/07, Fred Jones fredthejonester@gmail.com wrote:
Make each box (not the pages) a separate node with it's own content.
My question is, however, regarding the body text of my box nodes. I am fetching it thusly:
$result5 = db_query("SELECT body from node_revisions where nid = ".$row->nid.";");
which works, but it returns the raw text, without the <p> tags added. Is there a Drupal function that will add them in for me?
Check out node_load (http://api.drupal.org/api/function/node_load/5) for fetching nodes. It will isolate you from worrying about revisions.
For insights into how Drupal renders nodes, check out node_view (http://api.drupal.org/api/function/node_view/5) Unless you want a fully themed node, you'll want to copy the appropriate code.
The page in question is setup like a FAQ where at the top are the questions, each with a link to the answer.
It sounds like your mostly done and happy with your implementation, so probably not worth going back and changing. However, at some point you'll want to check the Views and CCK modules for this kind of thing. You can do some really kick-ass cool stuff.
Check out node_load (http://api.drupal.org/api/function/node_load/5) for fetching nodes. It will isolate you from worrying about revisions.
Perfect. Thanks.
For insights into how Drupal renders nodes, check out node_view (http://api.drupal.org/api/function/node_view/5) Unless you want a fully themed node, you'll want to copy the appropriate code.
Thanks. Indeed mine are fully themed, but this is good to know.
The page in question is setup like a FAQ where at the top are the questions, each with a link to the answer.
It sounds like your mostly done and happy with your implementation, so probably not worth going back and changing. However, at some point you'll want to check the Views and CCK modules for this kind of thing. You can do some really kick-ass cool stuff.
The node itself is indeed CCK. I know Views, but as I said, I don't see a way to generate two lists of the node return set, one list of links and one list of content, on the same page. If there IS such a way, let me know. :)
Thanks a lot!
Fred
The node itself is indeed CCK. I know Views, but as I said, I don't see a way to generate two lists of the node return set, one list of links and one list of content, on the same page. If there IS such a way, let me know. :)
Views is amazing once you wrap your head around! With the caveat that I've done this before, but haven't tested this specific code .....
If you create a list view, the Views Theme Wizard gives code along the following lines to place in your template.php file:
function phptemplate_views_view_list_faq($view, $nodes, $type) { <<< SNIP >>> foreach ($nodes as $i => $node) { $vars = $base_vars; $vars['node'] = $node; $vars['count'] = $i; $vars['stripe'] = $i % 2 ? 'even' : 'odd'; foreach ($view->field as $id => $field) { $name = $field_names[$id]; $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); if (isset($field['label'])) { $vars[$name . '_label'] = $field['label']; } } $items[] = _phptemplate_callback('views-list-faq', $vars); } if ($items) { return theme('item_list', $items); } }
This line calls out to the template file views-list-faq.tpl.php for formatting: $items[] = _phptemplate_callback('views-list-faq', $vars);
With the following change, you can format two different things with the same data: $link_items[] = _phptemplate_callback('views-list-faq-linkitem', $vars); $content_items[] = _phptemplate_callback('views-list-faq-contentitem', $vars);
This will call views-list-faq-linkitem.tpl.php and views-list-faq-contentitem.tpl.php. The names of the variables are the same for each file, so the info provided by the Theme Wizard for the tpl.php file is valid for both of these files.
This code: if ($items) { return theme('item_list', $items); }
calls theme_item_list (http://api.drupal.org/api/function/theme_item_list/5) on the array named $items. Each entry in $items is just a text string (created using the tpl.php file via _phptemplate_callback). Instead of calling theme_item_list to convert the array of strings into an unordered list, you can do something like this:
if ($link_items) { $result = '<div class="faq-links">'; $result .= theme('item_list', $link_items); $result .= '</div>'; $result .= '<div class="faq-contents">'; foreach($content_items as $item) { $result .= $item; } $result .= '</div>'; return $result; }
C'est voila!