Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Insert html code into a string

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
jfernandes
Smarty n00b


Joined: 21 Oct 2013
Posts: 1

PostPosted: Mon Oct 21, 2013 4:41 pm    Post subject: Insert html code into a string Reply with quote

Hi all,

Smarty noob here.

Im a front end dev and we use smarty 2.

We have a bit of code that output the days of the week in table cells and other stuff

Code:
            {php}
            $dealer = $this->get_template_vars('dealer');
            $department = $this->get_template_vars('department');

            $opentimes = array();
            if($dealer->opentimes[$department]){
                foreach($dealer->opentimes[$department] as $key => $item){
                $tmp = array();
                if((isset($item['closed_all_day'])) && ($item['closed_all_day']==='yes')){
                    $tmp[] = '(Closed)</td><td>&nbsp;';
                }
                elseif((isset($item['Monday'])) && ($item['closed_all_day']==='yes')){
                    $tmp[] = '(Closed)</td><td>&nbsp;';
                }
                else {
                    if(!empty($item['close_am'])){
                        $item['close_am'] = ' - '.$item['close_am'];
                    }
                    if(!empty($item['open_pm'])){
                        $item['open_pm'] = $item['open_pm'].' - ';
                    }
                    $tmp[] = $item['open_am'].$item['close_am'];
                    $tmp[] = $item['open_pm'].$item['close_pm'];
                }
                $opentimes[$key] = $tmp;
                }
            }
            $this->assign('openingtimes',$opentimes);
            {/php}


Followed by:

Code:
                {if $openingtimes}
                    {foreach from=$openingtimes key=key item=item}
                    <tr>
                        <td>{$key|capitalize}</td>
                        {foreach from=$item key=key2 item=item2}
                        <td class="times">{$item2}</td>
                        {/foreach}
                    </tr>
                    {/foreach}
                {/if}


I'm working on a responsive template and I want it so what on a mobile it only shows the first 3 characters of the day (Mon, Tue, Wed, Thu, Fri)

So I need to count the first 3 characters and then wrap the rest in this <span class="mobHide">REST OF STRING</span>

Is this possible? Thanks in advance.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP