Results 1 to 6 of 6

Thread: IF condition not working on home

  1. #1
    Join Date
    Feb 2008
    Posts
    23

    Default IF condition not working on home

    If a listing has an image it is displayed. If not then a default image is shown

    I got this by adding the following code in details_link.html

    <%if $content%>
    <img src="<%$site_url%>/thumbs/<%$logo%>.jpg" /></a>

    <%else%>

    <img src="/images/nologo.jpg" /></a>
    <%/if%>

    Because i wanted the same on my home i added the following code in
    block_random_listing_rows.html

    <%if $content%>
    <img src="<%$site_url%>/thumbs/<%$logo%>.jpg" /></a>

    <%else%>

    <img src="/images/nologo.jpg" /></a>
    <%/if%>

    Then i tried it with

    <%if $logo%>
    <img src="<%$site_url%>/thumbs/<%$logo%>.jpg" /></a>

    <%else%>

    <img src="/images/nologo.jpg" /></a>
    <%/if%>

    Then i tried it with another db field called logo2(with the name of the image)

    <%if $logo%>
    <img src="<%$site_url%>/thumbs/<%$logo%>.jpg" /></a>

    <%elseif $logo2%>

    <img src="/images/nologo.jpg" /></a>
    <%/if%>

    But nothing works. Why does it work in on the detail page, and not on the homepage?

    Tom

  2. #2
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    Because the variable in question is not available on index.php, only on detail.php

  3. #3
    Join Date
    Feb 2008
    Posts
    23

    Default

    Wow fast reply. Thank you.

    But how does i make it work on index.php.

    Which variable to use it on index.php?

    I hope you can help me.
    Tom

  4. #4
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    To make it work you'd need to carry over the variables and any associated code in the .php file(s).

  5. #5
    Join Date
    Feb 2008
    Posts
    23

    Default

    Hi Bruce,

    Can you show me an example. Let's start with the detail page.

    In the detail_link.html i use this code:
    <%if $logo%>
    <img src="<%$site_url%>/thumbs/<%$logo%>.jpg" /></a>

    <%else%>

    <img src="/images/nologo.jpg" /></a>
    <%/if%>

    so in detail.php i must add ?

    if (!empty($logo)) {
    $logo= "<img src="/thumbs/$logo>.jpg" />";
    }
    else {
    $logo= "<img src="/thumbs/nologo.jpg" />";
    }


    Tom

  6. #6
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    You don't use if statements in the .php files. That will only cause issues.

    // vars global configuration
    global $dbConn, $theme_path, $number_of_links_format, $category_separator,
    $cat_default_image, $cat_columns, $max_sub_cat, $cat_link_style,
    $subcat_link_style, $cat_table_width, $cat_cellspacing,
    $theme_name, $cat_description_format;

    You would need to add the variable you want to that list, plus add any code onto index.php to make that variable work.

    This is something you're going to have to figure out on your own, I'm not a programmer and custom programming isn't part of support.

    There are examples on the forum from other users however, perhaps that can help you. Or if you'd like you can email custom [at] nicecoder.com and we can get you a quote to do this.

Similar Threads

  1. Home Page Advertisement
    By DGTALGOODIES in forum Website development, hosting and promotion
    Replies: 8
    Last Post: 08-07-2008, 06:41 AM
  2. indexuthemes.com anybody home?
    By TLDnetworks in forum Templates
    Replies: 2
    Last Post: 02-17-2008, 05:16 PM
  3. Adsense On Your Home Page
    By exploreflorida in forum Tutorials, Hints & Tips
    Replies: 19
    Last Post: 01-14-2008, 01:14 PM
  4. <title> of the home page.
    By Dorian in forum v5.x
    Replies: 2
    Last Post: 08-15-2006, 03:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •