2 questions about smarty

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Man-wai Chang

    2 questions about smarty

    1. How could concatenate two values into a string in the template?

    {section name=j start=0 loop=10 step=1}
    {section name=k start=0 loop=10 step=1}
    {assign var=xx value=concat($s marty.section.j ,$smarty.sectio n.k)}
    {xx}
    {/seection}
    {/section}

    2. How could I address/use associative array in the template? I could do
    it with numbers, but it will be more self-documentating if I could use
    assoc. array....

    --
    iTech Consulting Services Limited
    Expert of ePOS solutions
    Website: http://www.itech.com.hk (IE only)
    Tel: (852)2325 3883 Fax: (852)2325 8288
  • Man-wai Chang

    #2
    Re: 2 questions about smarty

    1. How could concatenate two values into a string in the template?
    >
    {section name=j start=0 loop=10 step=1}
    {section name=k start=0 loop=10 step=1}
    {assign var=xx value=concat($s marty.section.j ,$smarty.sectio n.k)}
    I gave up and use PHP codes to do it.

    <?php $combined="COL{ $part1}ROW{$par t2}"; ?>
    <input type="textbox" id="txtQty<?ph p echo $combined; ?>">
    {xx}
    {/seection}
    {/section}
    2. How could I address/use associative array in the template? I could do
    it with numbers, but it will be more self-documentating if I could use
    assoc. array....
    >
    It's {$array[i][j].attribute}. But what if the index is not in the end?
    Will {$array[i].attribute.[j]} work?

    --
    iTech Consulting Services Limited
    Expert of ePOS solutions
    Website: http://www.itech.com.hk (IE only)
    Tel: (852)2325 3883 Fax: (852)2325 8288

    Comment

    • Toby A Inkster

      #3
      Re: 2 questions about smarty

      Man-wai Chang wrote:
      {section name=j start=0 loop=10 step=1}
      {section name=k start=0 loop=10 step=1}
      {assign var=xx value=concat($s marty.section.j ,$smarty.sectio n.k)}
      {xx}
      {/seection}
      {/section}
      Yes, using Smarty is so much easier than using a full blown scripting
      language. ;-)

      --
      Toby A Inkster BSc (Hons) ARCS
      Fast withdrawal casino UK 2025 – Play now & cash out instantly! Discover the top sites for rapid, secure payouts with no delays.

      Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

      * = I'm getting there!

      Comment

      • Mitul

        #4
        Re: 2 questions about smarty

        On Apr 23, 2:28 pm, Man-wai Chang <toylet.toy...@ gmail.comwrote:
        1. How could concatenate two values into a string in the template?
        >
        {section name=j start=0 loop=10 step=1}
        {section name=k start=0 loop=10 step=1}
        {assign var=xx value=concat($s marty.section.j ,$smarty.sectio n.k)}
        {xx}
        {/seection}
        {/section}
        >
        You can concatenate by following way
        {assign var=xx value=$smarty.s ection.j|cat:$s marty.section.k }

        2. How could I address/use associative array in the template? I could do
        it with numbers, but it will be more self-documentating if I could use
        assoc. array....
        Read smarty manual for this .... You will get better idea from there
        itself. :)
        iTech Consulting Services Limited
        Expert of ePOS solutions
        Website:http://www.itech.com.hk(IE only)
        Tel: (852)2325 3883 Fax: (852)2325 8288

        Comment

        • Man-wai Chang

          #5
          Re: 2 questions about smarty

          You can concatenate by following way
          {assign var=xx value=$smarty.s ection.j|cat:$s marty.section.k }
          let me try....
          Read smarty manual for this .... You will get better idea from there
          itself. :)
          is $array[i][j].attribute the same as $array.i.j.attr ibute?

          --
          iTech Consulting Services Limited
          Expert of ePOS solutions
          Website: http://www.itech.com.hk (IE only)
          Tel: (852)2325 3883 Fax: (852)2325 8288

          Comment

          • Man-wai Chang

            #6
            Re: 2 questions about smarty

            >
            Yes, using Smarty is so much easier than using a full blown scripting
            language. ;-)
            I am looking for a code generator, to be exact. If you used Foxpro/DOS
            or Foxpro/Windows before, you would know what I meant. LAMP is a long,
            long road from Foxpro in terms of speed and ease of development.

            --
            iTech Consulting Services Limited
            Expert of ePOS solutions
            Website: http://www.itech.com.hk (IE only)
            Tel: (852)2325 3883 Fax: (852)2325 8288

            Comment

            • Man-wai Chang

              #7
              Re: 2 questions about smarty

              You can concatenate by following way
              {assign var=xx value=$smarty.s ection.j|cat:$s marty.section.k }
              {assign var=xx value=$smarty.s ection.j|cat:ca t:$smarty.secti on.k}

              Um... I got "Array" as output.

              And how could I show the version of smarty?



              --
              iTech Consulting Services Limited
              Expert of ePOS solutions
              Website: http://www.itech.com.hk (IE only)
              Tel: (852)2325 3883 Fax: (852)2325 8288

              Comment

              • Man-wai Chang

                #8
                Re: 2 questions about smarty

                is $array[i][j].attribute the same as $array.i.j.attr ibute?

                ok... figured it out.

                $array[$ileft].attribute is the same as $array.$ileft.a ttribute!

                In short, the square brackets could be replaced by a dot.

                --
                iTech Consulting Services Limited
                Expert of ePOS solutions
                Website: http://www.itech.com.hk (IE only)
                Tel: (852)2325 3883 Fax: (852)2325 8288

                Comment

                Working...