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

  • SEARCH
  • Home
  • 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 975499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:35:37+00:00 2026-05-16T03:35:37+00:00

Is it possible to use CCK to add a conditional to the image attach

  • 0

Is it possible to use CCK to add a conditional to the image attach module form where unless I have selected an image to use for a content node, certain fields are not visible?

Currently I do not have any operations available for my image attach field in my content type definition where configure and remove are available for all other fields.

  • 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-05-16T03:35:38+00:00Added an answer on May 16, 2026 at 3:35 am

    This would be really simple in your theme, e.g. node-foo.tpl.php for the content-type foo, that has a field “video”

    <?php if(!empty($field_video[0]['view'])): ?>
      <div class="block video">
         <?php print $field_video[0]['view'] ?>
      </div>
         <?php print $field_some_other[0]['view'] ?>
         <?php print $field_the_other_one[0]['view'] ?>
    <?php endif; ?>
    

    Some notes on style and best practices:

    I prefer the if/endif in templates, others prefer the if() {}. Technically little difference, I think elseif; is more readable in HTML.

    Technically it is not correct to simply print a value, but one should use drupal_render(). I personally still prefer print, because of its transparancy and simplicity. Drupal_render(), however, registers what it has “rendered” and allows you to drupal_render($node) at the end, to render all unrendered fields; very usefull if you decide to add fields later on, whithout having to change the entire template every time you do so. Drupal_render is not available in the tpl.php, but in the preprocessing: as sayd, a lot less transparent and slightly more complex.

    Dont! Ever! print the $field_foo[0][‘value’], always the [‘view’] part: the first is unescaped and may (will!) contain XSS injections and the likes.

    The strange nested array ($field_foo[0][‘value’]) is a result of the multiple-fields option in Drupal. A better way would be to always iterate over each field and never just render, hardcoded, the first ([0]) item. However, for reasons of readability, simplicity and transparancy, I prefer to hardcode the indexes in my template. Others (rightfully) disagree with me on this.

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

Sidebar

Related Questions

No related questions found

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.