Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Need help with a code

    Hey guys,

    Please check out the following code. It all works, but I would like to add the following. Once the count is 4, I would like to add a linebreak. Also when it is 8, and so on.

    This is the code from a mod for a forum, and it is displaying images on the left side below the username. It all works fine, but I would like to add a linebreak after 4 images have been shown, so when the count is 4, add a linebreak. How would I implement this in the code below?

    PHP Code:
        /**
        * Generate a slick new box of mini shop item icons, per member
        */    
        
    public function miniBoxedShopItems($mid$maxToShow=100)
        {
            
    $miniShopItemBoxHTML "";
            
    $shopItems = array();
            
            
    #portfolio cache enabled?
            
    if ( ! $this->settings['eco_general_cache_portfolio'] )
            {
            
                
    $shopItems $this->registry->mysql_ibEconomy->grabPortfolioItemsByType('shopitem'$midfalsetrue);
            }
            else
            {
                
    $this->ecoCacheLoader'portfolios' );
                
    $shopItems $this->caches['ibEco_portfolios'][ $mid ][ 'shopitems_'];
            }
            
            
    $disallowedItems explode(','$this->settings['eco_disallowed_box_items']);
            
            
    //$this->showVars($disallowedItems );
            
    if (is_array($shopItems ) && count($shopItems ))
            {
                
    $count 0;
                foreach (
    $shopItems AS $shopItem)
                {
                    
    $info pathinfo($shopItem['si_file']);
                    
    $file_name =  basename($shopItem['si_file'],'.'.$info['extension']);            

                    if (
    in_array(basename($file_name), $disallowedItems))
                    {
                        continue;
                    }
                    
                    
    $shopItem['si_url_image']    = $this->registry->ecoclass->awardImageURL($shopItem);
                    
    $imageSrc                     $this->customItemImageHTML($shopItem['si_image'], 'tag_blue.png'false$shopItem['si_url_image'], falsefalsetrue);
                    
    $imageStyle                 = ($shopItem['si_image']) ? "" "style='height:16px;width:16px; padding:8px;'";
                    
    $title                        = (!$this->request['f']) ? "title='{$this->lang->words['view_further_details']}'" "";

                    
    $miniShopItemBoxHTML .= 
                    
    "<a href='{$this->settings['base_url']}app=ibEconomy&amp;tab=shop&amp;area=single&amp;type=shopitem&amp;id={$shopItem['p_type_id']}&amp;bank_type={$shopItem['p_type_class']}' class='__item __id{$shopItem['p_type_id']}__type_shopitem_x' {$title}>
                        <img src='{$imageSrc}' {$imageStyle} class='ipsUserPhoto ipsUserPhoto_mini' data-tooltip='{$shopItem['si_title']}' />
                    </a>"
    ;
                    
                    
    $count++;
                    
                    if (
    $count == $maxToShow)
                    {
                        break;
                    }    
                }
            }
            
            return 
    $miniShopItemBoxHTML;
        }

    So it should be added somewhere in this code I believe:

    PHP Code:
                    $miniShopItemBoxHTML .= 
                    
    "<a href='{$this->settings['base_url']}app=ibEconomy&amp;tab=shop&amp;area=single&amp;type=shopitem&amp;id={$shopItem['p_type_id']}&amp;bank_type={$shopItem['p_type_class']}' class='__item __id{$shopItem['p_type_id']}__type_shopitem_x' {$title}>
                        <img src='{$imageSrc}' {$imageStyle} class='ipsUserPhoto ipsUserPhoto_mini' data-tooltip='{$shopItem['si_title']}' />
                    </a>"
    ;
                    
                    
    $count++; 

  • #2
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Thanks vey much, got it to work with this.

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I don't see the need to add another counter as there is one already there.
    PHP Code:
    $miniShopItemBoxHTML .=  
                    
    "<a href='{$this->settings['base_url']}app=ibEconomy&amp;tab=shop&amp;area=single&amp;type=shopitem&amp;id={$shopItem['p_type_id']}&amp;bank_type={$shopItem['p_type_class']}' class='__item __id{$shopItem['p_type_id']}__type_shopitem_x' {$title}> 
                        <img src='{$imageSrc}' {$imageStyle} class='ipsUserPhoto ipsUserPhoto_mini' data-tooltip='{$shopItem['si_title']}' /> 
                    </a>"

                     
                    
    $count++;
    if((
    $count 4) == 0)
    {
    $miniShopItemBoxHTML .= '<br />';

    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    With you code you posted you uses $kount which is different from the existing counter they had (when you could have just used $count to begin with) so the OP probably took your example, added another $kount variable and then copied the code you gave them directly into theirs.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Still got a question though. I have fixed it like this now, very simple:

    PHP Code:
                    $miniShopItemBoxHTML .= 
                    
    "<a href='{$this->settings['base_url']}app=ibEconomy&amp;tab=shop&amp;area=single&amp;type=shopitem&amp;id={$shopItem['p_type_id']}&amp;bank_type={$shopItem['p_type_class']}' class='__item __id{$shopItem['p_type_id']}__type_shopitem_x' {$title}>
                        <img src='{$imageSrc}' {$imageStyle} class='ipsUserPhoto ipsUserPhoto_mini' data-tooltip='{$shopItem['si_title']}' />
                    </a>"
    ;

                    
    $count++;
                    
                    if(
    $count%== 0){
                    
    $miniShopItemBoxHTML .= 
                    
    "<br /><br />";
                    } 
    And it is being displayed as in the below example:

    http://img716.imageshack.us/img716/9125/test3u.png

    But I would like it to be displayed as in the below example:

    http://img194.imageshack.us/img194/3374/test2im.png

    So without that big linebreak. Any ideas how to accomplish this?

  • #6
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Thanks, I tried that but it just displays the same as if I wouldn't use a <br />

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    That means there is something else going on in your code. Do you have a link to the site?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts
    I do, but it's a new site, well forum actually, but I do not want to launch it and make it public yet.. :P I tested some things and with more images it does look appealing so I am going to keep it like this for now, and later I will still want to change it so I'll post the link to the site here then Thanks for the help!
    Last edited by Hardist; 05-12-2012 at 09:56 AM.

  • #9
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts
    These are the settings, but I cannot seem to find anything that would cause this difference in height:

    PHP Code:
    .ipsUserPhoto {
        
    padding1px;
        
    border1px solid #515151;
        
    background#393939;
        
    -webkit-box-shadow0px 2px 2px rgba(0,0,0,0.1);
        -
    moz-box-shadow0px 2px 2px rgba(0,0,0,0.1);
        
    box-shadow0px 2px 2px rgba(0,0,0,0.1);
    }
        
        .
    ipsUserPhotoLink:hover .ipsUserPhoto {
            
    border-color#5f5f5f;
            
    -webkit-box-shadow0px 2px 2px rgba(0,0,0,0.2);
            -
    moz-box-shadow0px 2px 2px rgba(0,0,0,0.2);
            
    box-shadow0px 2px 2px rgba(0,0,0,0.2);
        }
        
        .
    ipsUserPhoto_variable max-width155px; }
        .
    ipsUserPhoto_large max-width90pxmax-height90px; }
        .
    ipsUserPhoto_medium width50pxheight50px; }
        .
    ipsUserPhoto_mini width30pxheight30px; }
        .
    ipsUserPhoto_tiny width20pxheight20px;    }
        .
    ipsUserPhoto_icon width16pxheight16px;    } 

  • #10
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    We need to see more of your HTML output as well as your CSS. It is possible you have some CSS that makes things display block somewhere for you links. Right now we are just kind of guessing.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #11
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Here's a link to a topic view:

    http://www.touchofdarkness.com/index...our-community/

    As you can see on the left side, it is being displayed correctly now with the code that was provided, thanks again for that, but I would like it to be displayed like in this example:

    http://img194.imageshack.us/img194/3374/test2im.png

    So the spacing between the two images should be the same in all directions, so on the two sides aswell as the bottom and top.

  • #12
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I'm only seeing one picture on the left side, not multiple pictures like you show in your example.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #13
    New Coder
    Join Date
    Aug 2010
    Posts
    53
    Thanks
    6
    Thanked 1 Time in 1 Post
    set margin:0; and padding:0; to your images and maybe even clear:both;

  • #14
    New to the CF scene
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Could you help me with this code to used in another version punBB..?thank you...
    Last edited by ddr3; 05-19-2012 at 01:29 AM.

  • #15
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Wuteverx1972 View Post
    set margin:0; and padding:0; to your images and maybe even clear:both;
    Tried all this but did not work. The problem is that there are just a lot of files and css files aswell, cuz it's an invision forum, so it's kinda hard to find where it goes "wrong".


  •  

    Posting Permissions

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