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

    Join Date
    Jan 2014
    Posts
    8
    Rep Power
    0

    Selecting icons' positioning


    For my navigation buttons of my mobile website I have the option to select an icon for every page as can be seen here:


    The icon can be positioned on the left side of the page title using this code:
    PHP Code:
    if($page->buttonicon){
        
    $icon "<img src=\"icons/".$page->buttonicon."\" style=\"position:relative; top:33px\">";
        }
    else{
        
    $icon "<img src=\"images/noicon.png\" style=\"position:relative; top:33px\">";
        }

    $menurow "<li id=row_".$page->id." style=\"display:$rstyle\">$icon<a class=\"".$bs."\" href=\"".trim($page->url)."\" $target >".$page->title."</a></li>\n"
    Or on its right side with this piece of code:
    PHP Code:
    if($page->buttonicon){
        
    $icon "<img src=\"icons/".$page->buttonicon."\" style=\"position:relative; right: -240px; top:33px\">";
        }
    else{
        
    $icon "<img src=\"images/noicon.png\" style=\"position:relative; right: -240px; top:33px\">";
        }

    $menurow "<li id=row_".$page->id." style=\"display:$rstyle\">$icon<a class=\"".$bs."\" href=\"".trim($page->url)."\" $target >".$page->title."</a></li>\n"
    Currently I manually adjust the position of the icons. Therefore I would like to have the option to select a position (left or right) after having selected the specific icon. See example:


    I made up a code for selecting the icon's position.
    Code:
    <tr>
    <td align="left" valign="top" class="inputlabels">Icon positioning</td>
    <td>
    <?
    $sel_buttoniconpos[$page->buttoniconpos] = 'selected';
    ?>
    <select name="buttoniconpos" id="buttoniconpos">
    <option value="Left" <?=$sel_buttoniconpos['Left']?> >Left</option>
    <option value="Right" <?=$sel_buttoniconpos['Right']?> >Right</option>
    </select></td>
    </tr>
    Question: how do I combine the first two codes so that I can select the icon's position after having selected the icon? Iím aware of the fact that the code is not the clean way, but as I am a beginner I would like to stick to using the codes above as a base.

    Any help is highly appreciated, many thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    67
    Rep Power
    0
    I feel like I might be missing something. Why do you have to "position" them, and not float them left or right?

IMN logo majestic logo threadwatch logo seochat tools logo