Zikula: A Flexible Open Source Content Management System
home | forum | international support | contact us

Support Forum

Start ::  Extensions and Distributions Support ::  Modules ::  How can I nest a IF then ELSE structure like this?

Moderated by: Support Team

Bottom
How can I nest a IF then ELSE structure like this?

  • Link to this postingPosted: 17.03.2005, 19:50
    Profile
    michiel
    rank:
    Freshman Freshman
    registered:
     April 2004
    Status:
    offline
    last visit:
    30.07.08
    Posts:
    30
    Hi,

    I have a problem, my knowledge’s about PHP is limited.

    I use the 2.1 version of the Updownload module on PN .750 gold (http://www.petzi-juist.de/)

    The module shows screenshots next to the downloads on the right site. I managed to move the screenshot to the left side with success. The only problem is if there is no images available it show noting. I traced down the piece of code responsible for this. Look at the following code:

    File name: dl-util.php

    //
    //shows the screenshot
    //thanks to: Luis Carlos Bethancourt
    //
    function get_screenshot($lid)
    {
    include("modules/UpDownload/includes/config.php");

    echo "
    <center>";
    if($screenshotlink =="")
    {
    $screenshotlink = "modules/UpDownload/shots";
    }

    while($ext = current($screenshot_extensions))
    {
    if(file_exists($screenshotlink."/thumbs/$lid".$ext))
    {
    $fp = @fopen($screenshotlink."/thumbs/$lid".$ext,"r");
    $small_ext = $ext;
    }

    if(file_exists($screenshotlink."/$lid".$ext))
    {
    $fp = @fopen($screenshotlink."/thumbs/$lid".$ext,"r");
    $large_ext = $ext;
    }
    next($screenshot_extensions);
    }

    if ($fp)
    {
    if(file_exists($screenshotlink."/$lid".$large_ext))
    {
    // echo "\""._FULLSCREENSHOT."\" echo "\""._FULLSCREENSHOT."\" }
    else
    {
    // echo "\""._SCREENSHOT."\" echo "
    \""._SCREENSHOT."\" }

    echo "src=\"$screenshotlink/thumbs/$lid".$small_ext."\">
    ";

    /* else
    {
    echo _NOPICTURE."
    "._AVAILABLE ;
    */ }

    echo"</center>
    ";
    }


    As you can see there is a second ELSE structure!!
    When I un command the following lines I get a parser error

    else
    {
    echo _NOPICTURE."
    "._AVAILABLE ;
    }

    What’s wrong? How can I nest a IF then ELSE structure like this?

    I hope somebody can shine some light on this, so I and others can learn from this.

    Any help is appreciated,

    Michiel
  • Link to this postingPosted: 18.03.2005, 00:04
    Profile Homepage
    ctimmer
    rank:
    Helper Helper
    registered:
     February 2003
    Status:
    offline
    last visit:
    11.06.08
    Posts:
    226
    I think you need a '}' in front of the 'else' in error. As it stands you have an 'else' block that doesn't refer to any 'if'.
  • Link to this postingPosted: 18.03.2005, 03:23
    Profile
    michiel
    rank:
    Freshman Freshman
    registered:
     April 2004
    Status:
    offline
    last visit:
    30.07.08
    Posts:
    30
    Works like a charm Curt,
    Thanks for you advice.

Start ::  Extensions and Distributions Support ::  Modules ::  How can I nest a IF then ELSE structure like this?

Main Menu

Extensions Database

Documentation

Development

Login





 


 Log in Problems?
 New User? Sign Up!

Donate to Zikula