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 9036193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:55:40+00:00 2026-06-16T08:55:40+00:00

I have two normal fields in a view, one optional URL field and one

  • 0

I have two normal fields in a view, one optional URL field and one image field. I want that if the optional URL field is empty, the image render as normal, but if the optional URL field contains an URL, then print the mage wrapped in an “A” tag with the optional URL.

I managed to make the part of the Image wrapped in the A tag, but I dont know how to make that part optional.

Any help regarding this?

  • 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-16T08:55:41+00:00Added an answer on June 16, 2026 at 8:55 am

    Install this http://drupal.org/project/views_customfield module(only for D6) and you can add a custom php field in views.

    In Fields Section -> Choose Customfield -> and then add Customfield: PHP code

    Below is the sample code to get values

    <?php
    $static = $this->view->display_handler->get_handlers('field');
    $x=$static['field_image']->last_render;
    $y=$static['field_link']->last_render;
    
    if(empty($y))
    {
        print $x;
    }
    else
    {
        print $y;
    }
    ?>
    

    first line is like declaration and 2nd & 3rd are to get values from the fields.

    replace field_image & field_link with your own fields(see Replacement patterns for your fields)

    Using this sample code, change the conditions to your requirement.

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

Sidebar

Related Questions

I have two images. One that is normal, and another that is more colourised.
I have a form where I have multiple fields, but it's essential that two
I am using eclipse and I have two TextField such that one text field
I want to send the form data to server-side. I have two ways: Normal
In my iPad app I have two textfields. One displays the normal, default textfield
I have two classes (MVC view model) which inherits from one abstract base class.
I have two date fields that I need to join on. The first is
I have two Doctrine entities that have a one-to-many relationship, like this: License class
A pretty normal case: We have a 'portlet' composite component that has two states:
I have a JDialog which has two fields, username and password. I want to

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.