Results 1 to 10 of 14

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Blank Sidebox Image Won't Show

    Quote Originally Posted by Website Rob View Post
    It is stated that one can use PHP code within but I cannot figure out how and would like some guidance.
    I think you're going to have a "duh" moment

    Sideboxes work by loading up a variable called $content with the html that is to be output. The blank sidebox also follows this pattern. You can see this in action in the example in the previous post, and the examples in template file that comes in the mod's release pack.

    So to take your first example, which I assume you are puting into the tpl_blank_sidebox.php file, you can't put php tags in, because all the file contents are already inside php tags. Instead you would simply add your content to the string of HTML that is being built up by inserting

    $content .= 'Some text here';

    Or better still, give it a bit of structure

    $content .= '<p>Some text here</p>';
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  2. #2
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Blank Sidebox Image Won't Show

    I understand what you are saying but I'm looking to put in PHP code, not plain text or HTML.

    As stated within the module itself; tpl_blank_sidebox.php

    $content .= '<p>You can include text, links, images, HTML markup and even PHP code</p>';

    Can you provide an example of how PHP code would be used?

  3. #3
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Blank Sidebox Image Won't Show

    The example already given was PHP. A slightly more complex one would be:

    $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';

    Or you could use loops such as (taken from tpl_order_history.php)

    PHP Code:
      for ($i=1$i<=sizeof($customer_orders); $i++) {
            
    $content .= '<li><a href="' zen_href_link(zen_get_info_page($customer_orders[$i]['id']), 'products_id=' $customer_orders[$i]['id']) . '">' $customer_orders[$i]['name'] . '</a>&nbsp;&nbsp;<a href="' zen_href_link(basename($PHP_SELF), zen_get_all_get_params(array('action')) . 'action=cust_order&pid=' $customer_orders[$i]['id']) . '">' zen_image($template->get_template_dir(ICON_IMAGE_TINYCARTDIR_WS_TEMPLATE$current_page_base,'images/icons'). '/' ICON_IMAGE_TINYCARTICON_TINYCART_ALT) . '</a></li>' "\n" ;
      } 
    Any PHP really, just append the final output to the $content string.
    Last edited by kuroi; 1 Aug 2009 at 10:38 AM.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  4. #4
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Blank Sidebox Image Won't Show

    I just don't seem to be getting it. Almost seems like only certain types of PHP code can be used and/or the PHP code needs to be wrapped within HTML code.

    This is the code I am working with but can not yet get to work correctly.

    $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';

    $content .= '<p>' . TEXT_SHOPPINGCART_SIDEBOX . '</p>';
    $content .= '';
    $content .= '
    if ($_SESSION['cart']->count_contents() == 0) {
    $products = $_SESSION['cart']->get_products();
    echo 'Your Cart is Empty!';
    }

    if ($_SESSION['cart']->count_contents() > 0) {
    $products = $_SESSION['cart']->get_products();
    echo '' . $_SESSION['cart']->count_contents().' Item - ';
    echo $currencies->format($_SESSION['cart']->show_total());
    }';

    $content .= '</div>';


    The above code is used for the one-liner Shopping Cart display; number of items and dollar amount. Escaping any single quotes prevents parse errors but then the PHP code will not parse.

    Due to the setup of the Template I am working on, it is the code the works best but needs to be in a Sidebox.

  5. #5
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Blank Sidebox Image Won't Show

    Revised code ...
    PHP Code:
    $content '';
    $content .= '<p>' TEXT_SHOPPINGCART_SIDEBOX '</p>';

    if (
    $_SESSION['cart']->count_contents() == 0) {
      
    $content .= 'Your Cart is Empty!';
    }

    if (
    $_SESSION['cart']->count_contents() > 0) {
      
    $products $_SESSION['cart']->get_products();
      
    $content .= $_SESSION['cart']->count_contents().' Item - ' .  $currencies->format($_SESSION['cart']->show_total());
    }

    $content .= '</div>'
    Here's what I did and why (line numbers refer to your original code) ...
    • Reversed the 1st and 2nd lines, and removed the concate "." from the now 1st line so that any contents left over from the previous sidebox are cleared out.
    • Removed line 3, you don't want to append your processing logic to the $content string.
    • You want to append the results of that logic.
    • Removed line 6, if the count is 0, there are no products to get
    • In line 7, appended the output, instead of trying to echo it prematurely (echoing will be done later by Zen Cart).
    • Similarly lines 12 and 13 which I also cleaned up and merged (you may want to add some HTML here to to provide some structure when it's output.
    • Removed some superfluous stuff from line 14

    I haven't tried to test this, so please do post back and let me know how it goes.

    The above code still retrieve the product list from the cart when there are some, but you will probably want to get rid of that too, unless you plan to take this further and expand and display them.
    Last edited by kuroi; 1 Aug 2009 at 11:04 AM. Reason: Remove concate dot
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  6. #6
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Blank Sidebox Image Won't Show

    Oops. The following should be inserted between the first and second lines

    $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">' . "\n";

    Always need this for a 1.3 sidebox.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  7. #7
    Join Date
    Oct 2006
    Location
    Alberta, Canada
    Posts
    4,571
    Plugin Contributions
    1

    Default Re: Blank Sidebox Image Won't Show

    Your code works a treat, kuroi... thanks.

    I can see how you removed all 'echo' statements and replaced with the append: $content .=
    I take it 'echo' statements will not work or is it a case a of being able to properly tweak when needed?

    Reason I ask is that I tried adding the following to your code, just above and then below the closing DIV statement.

    echo zen_image(DIR_WS_TEMPLATES . $template_dir . '/images/some_image.jpg','alt text goes here');

    Although it worked, image was displayed, it was outside and above the Sidebox both times. Various trial & error methods could not get the image to display within the Sidebox.


    Also, original module code does not use a "\n"; at the end of the opening DIV line but I guess it makes no difference?

  8. #8
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Blank Sidebox Image Won't Show

    Sideboxes are built before the the page is rendered and their output stored until the right time to output it comes along. This means that content that is echoed will be sent to the browser, but ahead of the stuff it should be with. That's why you could see it, but not persuade it to go nicely into its box.

    However, the following should achieve what you want, where you want it ...
    $content .= zen_image(DIR_WS_TEMPLATES . $template_dir . '/images/some_image.jpg','alt text goes here');

    The "\n" are newlines that will impact your source code only. Without them big clumps (techie term) of html tend to end up on the same line. Works just as well from a visitor's viewpoint, but can be a pain to debug if you've got a structural issue, so I tend to spread the "\n" around liberally.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

 

 

Similar Threads

  1. v150 SSL image won't show up
    By abundancy in forum General Questions
    Replies: 1
    Last Post: 10 Jan 2013, 03:31 AM
  2. v150 css problem - my background-image won't show
    By Kathy_ in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 20 May 2012, 11:43 PM
  3. Blank Sidebox v2.0 Header won't change
    By Tamuren in forum Templates, Stylesheets, Page Layout
    Replies: 30
    Last Post: 12 Jul 2011, 02:55 PM
  4. blank sidebox mod - won't let me add an image
    By zubenubi in forum General Questions
    Replies: 2
    Last Post: 1 Jul 2010, 06:07 PM
  5. whats_new sidebox won't show up
    By egpeters in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 20 Aug 2008, 01:33 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
  •  
disjunctive-egg