Forums

Include php and widgets dispearing (2 posts)

  1. djavet
    Member
    Posted 1 year ago #

    Hi,

    I wish include an external php file from a random gallery (4images) into the index.php of my theme. I put the include tag into the index.php page of my main theme and add the random-picture.php into my child theme.

    I use this code in the main theme:
    <?php get_template_part( 'random', 'picture' ); ?>

    and put the random-picture.php into the child theme. It work well with a simple php echo.

    But once I add the following code, my footer links and tags widgets dispear from the footer, same with the recents entries in the sidebar (you can still see them in the detail -> http://www.john-howe.com/blog):
    [code]
    <div id="random-pictures">
    <?php
    // PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
    define('ROOT_PATH', '../portfolio/gallery/');
    include(ROOT_PATH.'config.php');
    include(ROOT_PATH.'includes/db_mysql.php');
    include(ROOT_PATH.'includes/constants.php');

    $site_db = new Db($db_host, $db_user, $db_password, $db_name);
    function is_remote($file_name) {
    return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
    }

    // NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEW?SCHTEN THUMBNAILS
    $num_images = 0;

    $sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments
    FROM (".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b)
    WHERE a.image_active=1
    AND a.cat_id = b.cat_id
    AND b.auth_viewcat=".AUTH_ALL."
    AND b.auth_viewimage=".AUTH_ALL."
    LIMIT 0, 5";
    $result = $site_db->query($sql);
    $new_images = "<table align=\"center\" border=\"0\">\n";
    $count = 0;
    $bgcounter = 0;
    while ($row = $site_db->fetch_array($result)){
    $image_id = $row['image_id'];
    $cat_id = $row['cat_id'];
    $image_name = $row['image_name'];
    $image_comments = $row['image_comments'];
    $thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
    if ($count == 0) {
    $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
    $new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $new_images .= "<td valign=\"top\">";
    $new_images .="<img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\">
    $image_name";
    $new_images .= "</td>\n";
    $count++;
    if ($count == 4) {
    $new_images .= "</tr>\n";
    $count = 0;
    }
    }

    if ($count > 0) {
    $leftover = (4 - $count);
    if ($leftover >= 1) {
    for ($f = 0; $f < $leftover; $f++) {
    $new_images .= "<td> </td>\n";
    }
    $new_images .= "</tr>\n";
    }
    }
    $new_images .= "</table>\n";

    echo $new_images;
    unset($new_images);
    ?>
    </div>
    [/code]

    Any idea why this happen? Is that regarding an incompatibility of the code? How solve it?

    A lot of thx for your advices.
    Regards,
    Dom

  2. djavet
    Member
    Posted 1 year ago #

    I found it! It the DB call, I need to use new wpdb and not new DB!

    Dom

Topic Closed

This topic has been closed to new replies.

About this Topic