Thread: Help with code

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0

    Help with code


    Hello there,

    I use a specific code to show content and tabs. I use this code:

    PHP Code:
     $antik_id  = $antik->id.'-'.uniqid();  
        $settings   = $antik->settings;  
        $content    = array();  
        $nav       = ($settings['navigation']) ? 'nav-'.$settings['navigation'] : '';  
        $item_width = floor(100 / count($antik->items));  
    ?>  

    <div id="slideshow-<?php echo $antik_id?>" class="wk-slideshow wk-slideshow-newtabs" data-antik="slideshow" data-options='<?php echo json_encode($settings); ?>'>  

     <div class="nav-container">  

            <ul class="nav clearfix">  
                <?php foreach ($antik->items as $key => $item) : ?>  
                <?php $title =  $item['title']; ?>  
                <?php $items2 '<li class="width'$item_width .'"><span>'$title .'</span></li>'?>  
                <?php $items[] = '<li class="width'$item_width .'"><article class="wk-content clearfix">'.$item['content'].'</article></li>'?>     
                <li>  
                    <span><?php echo $item[$items2]; ?></span>  

                </li>  
                <?php endforeach; ?>  
            </ul>  
        </div>  

        <div class="slides-container"><?php echo (count($items)) ? '<ul class="slides">'.implode(''$items).'</ul>' '';?></div>  

    </div>
    I get the tabs in a row and then the content (each content opens insise a tab). I am trying to put the tabs (tab with title) to use full width. For, example if i have 2 tabs then one tab will use 50% of width and the rest for the other tab. If i have 3 tabs then the percentage is 33% for each tab.


    The logic is this:
    We have the
    $item_width = floor(100 / count($widget->items));
    with which when generating items (tabs) and showing then the width divides equaly between tabs.
    Then in the foreach loop, i use the $title to store the title of the item, then i use the $items2 to use the item_width as class for the $title and then in the<li></li> tags i show the title. So, my logic is that inside these tags i will use this <?php echo $item[$items2]; ?>.

    But i get no titles instead. The only way to see the titles in the tabs are with this: <?php echo $item['title']; ?>, but the item_width class is not passed in the title.

    Any hint please?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,233
    Rep Power
    593
    Did you check what your HTML source looks like after it is rendered?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    If in the li tags I use this <?php echo $item['title']; ?> then I get the tabs and the content but the tabs do not use equal space
    Look at sportbeez . Com/ index.php/profile-view
    On top
    I need the tabs to use equal size each other with the item_width class
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,233
    Rep Power
    593
    Post the resulting HTML source (use [ CODE ] tags) and explain what you think it should be.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Οκ,

    With this code:

    PHP Code:
    <?php 

        $widget_id  
    $widget->id.'-'.uniqid();
        
    $settings   $widget->settings;
        
    $content    = array();
        
    $item_width floor(100 count($widget->items));

    ?>

    <div id="slideshow-<?php echo $widget_id?>" class="wk-slideshow wk-slideshow-pacetabs" data-widgetkit="slideshow" data-options='<?php echo json_encode($settings); ?>'>
        
        <div class="slides-container">

            <ul class="slides">
                <?php foreach ($widget->items as $key => $item) : ?>
                <?php $title $item['navigation'] ? $item['navigation'] : $item['title']; ?>
                <?php $items[] = '<li class="width'$item_width .'"><span>'$title .'</span></li>'?>
                <li>
                    <article class="wk-content clearfix"><?php echo $item['content']; ?></article>
                </li>
                <?php endforeach; ?>
            </ul>

            <?php echo (count($items)) ? '<div class="nav-container"><ul class="nav clearfix">'.implode(''$items).'</ul></div>' '';?>

        </div>

    </div>
    the result is this yootheme.com/demo/themes/joomla/2013/pace/ (at first of page there are 3 tabs and each tab uses equal width space.

    With the attached code from previous post and the use of <span><?php echo $item['title']; ?></span> inside of li tags, i get this result:

    sportbeez.com/index.php/el/profile-view

    So, i have managed to put the tabs on top of the content but the tabs do not appear like the first link (each tab to use equal width and to take advantage of the whole width)
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,233
    Rep Power
    593
    I am going to assume you are not posting the resulting HTML source because you don't know how. Posting the PHP source does not answer the question. In the browser, on the incorrect page, right click and select view page source (or something similar depending on the browser), examine that to see what PHP is really generating. Then post what you think is wrong and we can help correct it in PHP.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Ok,
    The html code from the incorrect page is this:
    Code:
    <div class="nav-container">
    <ul class="nav clearfix">
    <li>
    <span>Activity</span>
    </li>
    <li>
    <span>Information</span>
    </li>
    <li>
    <span>Find Members</span>
    </li>
    </ul>
    </div>
    where Activity, Information and Find Members are the Tab titles.
    The html code from the correct page is this:

    Code:
    <div class="nav-container">
    <ul class="nav clearfix">
    <li class="width33">
    <span><span class="slideshow-icon activities"></span>Activities</span>
    </li>
    <li class="width33">
    <span><span class="slideshow-icon easytracking"></span>Information</span>
    </li>
    <li class="width33">
    <span><span class="slideshow-icon synchronization"></span>Find Members</span>
    </li>
    </ul>
    </div>
    As you can see, at correct html code each tab title is inside <li class="width33"></li> tags.
    I need this class to be used to my tabs titles but instead i get only <li></li> tags (without the class).
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,233
    Rep Power
    593
    So now look at your code. Where are you outputting the <li> tags and where is the class attribute output?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Thank you very much for your help!

    I was trying to use item_width class inside li and it didn't work.
    Now, i just use
    <li class="width33"></li> tags and it works perfect!

    Thank you again!!!
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,233
    Rep Power
    593
    I was hoping you'd spot it on your own. All you were doing in your code was setting the value. If you wanted to output the value you need to 'echo' or 'print' it.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo