XML - > Smarty foreach和条件

时间:2013-04-05 12:31:15

标签: xml smarty

我对结果的智能模板代码有一些小问题。问题是接下来这个代码正在工作但是如果条件不能给我500个结果。代码看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<source>
<publisher>CMS</publisher>
<publisherurl><![CDATA[{$GLOBALS.site_url}]]></publisherurl>

    {foreach from=$listings item=listing}

        {if $listing.Country =='USA' || $listing.Country == 'UK' || $listing.Country == 'Russia'}

    <job>
        {$listings.foreach.Country.total} Total results
        <title><![CDATA[{$listing.Title}]]></title>

        <date><![CDATA[{$listing.activation_date}]]></date>
        <referencenumber><![CDATA[{$listing.id}]]></referencenumber>
        <url><![CDATA[{$listing.listing_url}]]></url>
        <company><![CDATA[{$listing.user.CompanyName}]]></company>
        <city><![CDATA[{$listing.City}]]></city>

        <country><![CDATA[{$listing.Country}]]></country>

        <description><![CDATA[{$listing.JobDescription|strip_tags:false} {$listing.JobRequirements|strip_tags:false}]]></description>
        <salary><![CDATA[{$listing.Salary.value} {foreach from=$listing.SalaryType item=list_value name="multifor"}{tr domain="Property_SalaryType"}{$list_value}{/tr}{if !$smarty.foreach.multifor.last}, {/if}{/foreach}]]></salary>

        <jobtype><![CDATA[{foreach from=$listing.EmploymentType item=list_value name="multifor"}{tr domain="Property_EmploymentType"}{$list_value}{/tr}{if !$smarty.foreach.multifor.last}, {/if}{/foreach}]]></jobtype>


    </job>

        {/if}    


    {/foreach}    

</source>

如果您看到或知道答案,请在下面发布,谢谢!

1 个答案:

答案 0 :(得分:0)

在$ listing上的php中做一个var_dump。你有多少记录&gt;