Results 1 to 3 of 3

Thread: Convert field to php array

  1. #1
    User
    Join Date
    06-19-09.
    Location
    Elbl?g, Poland
    Posts
    152

    Default Convert field to php array

    In my installation I use "catalogmultitextwizardfield" module.
    And in my Catalog module it works fine:


    Uploaded with ImageShack.us
    but in my template this module generates me strange code
    If I use this:
    Code:
    <?php echo $entry['data']['myField']['value']; ?>
    give me the data embeded into table. But I don't want table.

    If I use this:
    Code:
    <?php echo $entry['data']['myField']['raw']; ?>
    code looks like this:
    Code:
    <data>
    	<row>
    		<entry>Zakres pracy 900/1800 MHz</entry>
    	</row>
    	<row>
    		<entry>Radiacja H-360°, V -30°</entry>
    	</row>
    	<row>
    		<entry>Polaryzacja pionowa</entry>
    	</row>
    	<row>
    		<entry>Zysk 2dB</entry>
    	</row>
    	<row>
    		<entry>VSWR </entry>
    	</row>
    	<row>
    		<entry>Impedancja 50 ohm</entry>
    	</row>
    	<row>
    		<entry>Moc max. 10 W</entry>
    	</row>
    </data>
    It's seems like xml or something like this.

    How to convert this code into php array?
    Marcin

    http://www.contao.pl - Polish Support Site
    http://forum.contao.pl - Polish Contao community forum


    -----------------------
    Need custom template? Feel free to contact me by e-mail marcin@contao.pl

  2. #2
    User
    Join Date
    06-19-09.
    Location
    Elbl?g, Poland
    Posts
    152

    Default Re: Convert field to php array

    I solved this. Maybe it's not beautiful but it's works:
    Code:
    <?php $xml = simplexml_load_string($entry['data']['myField']['raw']); ?>
    <ul>
    <?php foreach ($xml->row as $col): ?>
    	<?php foreach ($col->entry as $spec): ?>
    		[*]<?php echo $spec; ?>
    	<?php endforeach; ?>
    <?php endforeach; ?>[/list]
    Marcin

    http://www.contao.pl - Polish Support Site
    http://forum.contao.pl - Polish Contao community forum


    -----------------------
    Need custom template? Feel free to contact me by e-mail marcin@contao.pl

  3. #3
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Convert field to php array

    Each catalog field integrator includes a rendered, which can be changed if you like. Not sure why it's XML as the raw rendered is usually from the database.

Bookmarks

Posting Permissions

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