Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8963139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:17:37+00:00 2026-06-15T16:17:37+00:00

I’ve just started learning how to use Drupal 7. I made a new content

  • 0

I’ve just started learning how to use Drupal 7. I made a new content type that will be displayed as a feed in my front page. All the data I need are being fetched and displayed correctly except for the image, whose url is always missing the actual file. I have another feed in my front page that uses the default article content type and all the images display properly.

The code I used for both is essentially the same, the only difference being the content type being retrieved.

This set worked:

$query = db_select('node', 'n');
$query->fields('n', array('nid', 'title'))
->condition('n.type', 'article')
->leftJoin('field_data_body', 'u', 'u.entity_id = n.nid');
$query->addField('u', 'body_summary');
$query->orderBy("nid", "desc");
$query->range(0, 3);
$result = $query->execute();

while($row = $result->fetchAssoc()) {
   $nid = $row['nid'];
   $node = node_load($nid);
   echo theme('image_style', array('style_name' => 'home-article-summary', 'path' => ($node->field_image['und'][0]['uri'])));
}

This didn’t:

$query = db_select('node', 'n');
$query->fields('n', array('nid', 'title'))
->condition('n.type', 'news') //the only difference between the two is this line
->leftJoin('field_data_body', 'u', 'u.entity_id = n.nid');
$query->addField('u', 'body_summary');
$query->orderBy("nid", "desc");
$query->range(0, 3);
$result = $query->execute();

while($row = $result->fetchAssoc()) {
   $nid = $row['nid'];
   $node = node_load($nid);
   echo theme('image_style', array('style_name' => 'home-article-summary', 'path' => ($node->field_image['und'][0]['uri'])));
}

I tried making the settings of the content type I created the same as the ones for article throught Structure->Content Types but nothing happened. What am I missing? Thank you.

edit:
Upon inspection, I couldn’t find a resized version of the image I uploaded for my custom content type. I’m assuming this means no resizing ever actually happened hence why the script didn’t return a file. I still don’t get why that happened.

edit the second:
never mind. I found the problem. it’s all working fine now. was just using the wrong variable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:17:38+00:00Added an answer on June 15, 2026 at 4:17 pm

    As a bit of friendly advice for a Drupal newcomer, consider using Views to display lists of content instead of writing heaps of custom database queries. That will save you lots of coding in the long run.

    Another argument for Views is that it’s going to be included in Drupal 8 core.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I need a function that will clean a strings' special characters. I do NOT
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.