Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By prettyeyes on
I'm using drupal 4.7, and wanted to use teasers for the main page.
I tried this code from here http://drupal.org/node/30967#comment-79533 :
<?php
$listlength="1";
$charlength="150";
$taxo_id = 1;
$content_type = 'story';
unset ($output);
$result1 = pager_query("SELECT n.title, n.nid, n.teaser, n.uid, n.created, u.name FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN term_node ON n.nid = term_node.nid WHERE n.type = '$content_type' AND term_node.tid = $taxo_id AND n.status = 1 ORDER BY n.created DESC", $listlength);
while ($node = db_fetch_object($result1)) {
$output .= l($node->title, "node/$node->nid") . "<br>" . substr(strip_tags($node->teaser), 0, $charlength) . "... <em>Submitted by " . $node->name . "</em>";
}
$output .= "<br>";
print $output;
?>
And I get this error:
user warning: Unknown column 'n.teaser' in 'field list' query: SELECT n.title, n.nid, n.teaser, n.uid, n.created, u.name FROM node n INNER JOIN users u ON n.uid = u.uid INNER JOIN term_node ON n.nid = term_node.nid WHERE n.type = 'story' AND term_node.tid = 1 AND n.status = 1 ORDER BY n.created DESC LIMIT 0, 1 in /home/comedyc/public_html/content/includes/database.mysql.inc on line 120.
Any suggestions?
Comments
Replace... not copy-paste
You'd better should look at your database. The n.* stuff represents your database. Therefor, find out what you should/could put in place for the n. by looking at your database?
How do I go about doing
How do I go about doing that, once I get to the database? I don't know what to replace it with.
ANYONE??????????
ANYONE??????????
4.6 code
I think this code is for 4.6 NOT 4.7. The database structure has changed. This might help: http://drupal.org/node/70369#comment-131933
---
Work: BioRAFT
Okay, it mentions a
Okay, it mentions a template.php. I'm using the phptemplate engine, but I don't see a template.php anywhere. I'm trying to see where I can get it,but I'm looking in all the wrong places. Do you know where I can spot it?
template.php not needed for you
With the other post, the output function was getting defined there. If your theme folder doesn't have a template.php, just create the file. See: http://drupal.org/phptemplate
Anyhow, the latter part of the code above will work to generate the output, but not to load the data.
Also, I'm not sure I really understand wht you're trying to achieve. You can just set all nodes of type 'story' to be promoted to the front page.
---
Work: BioRAFT
Let me start this over. I'm
Let me start this over.
I'm using the front_page module, as the main page has a slightly different theme than the rest.
On that page, there are EIGHT boxes. There's two boxes on the first row, three boxes on the second row, and three boxes on the third row. I created different node types for each subject, and each subject is to have their own box with their own teasers.
I created a template.php with:
And I created an item_list.tpl.php, but it has nothing in it. I'm confused about that one (Does anyone know if I need this file for my case, and am a little confused about template.php too. ?)
I used this snippet and put it in page.tpl.php:
And got this error:
user warning: Unknown column 'n.teaser' in 'field list' query: SELECT n.title, n.nid, n.teaser, n.uid, n.created, u.name FROM node n INNER JOIN users u ON n.uid = u.uid INNER JOIN term_node ON n.nid = term_node.nid WHERE n.type = 'story' AND term_node.tid = 1 AND n.status = 1 ORDER BY n.created DESC LIMIT 0, 1 in /home/comedyc/public_html/content/includes/database.mysql.inc on line 120.
I don't want a list of titles, but actual teasers that show the first few lines of the node's paragraph.
ok- but you still need code for 4.7!!!
The above SQL will not work. See the page I sent you to above for a working query/loop logic.
Also, do you really need a differnt node type for each box? Why not just a different taxonomy term?
Anhow the latter part is fine. Try something like:
---
Work: BioRAFT
That one I tried didn't
That one I tried didn't work. I didn't get any errors, it just shows up blank. And I made sure that the tax id number that I used existed.
I modified code for 4.7 like
I modified code for 4.7 like these...
now im looking for the way to strip img_assist code too ...no luck so far
www.ferjan.net