Jump to content

Recommended Posts

Posted

Hello

 

I am creating a bloc where I want to show 1 result BUT I want it to change every...10s I don't know.

I have my block and a understood how to filter my record using the ID.= :

{if !empty( $records ) }}
	<h3 class='ipsWidget_title ipsType_reset'>{$title}</h3>
	{{$Count = 0;}}
	{{if $orientation == 'vertical'}}
		<div class='ipsPad_half ipsWidget_inner'>
			<ul class='ipsDataList  ipsContained_container'>
              {{foreach $records as $record}}
              {$record->_id}
				{{if $record->_id === 29}}
					<li class='ipsDataItem'>
                      <div class='ipsType_break ipsContained'>
								<a href="{$record->url()->setQueryString( 'do', 'getLastComment' )}" title='{lang="view_this_cmsrecord" sprintf="\IPS\Member::loggedIn()->language()->addToStack( 'content_db_lang_sl_' . $record::$customDatabaseId, FALSE ), $record->_title"}' class='ipsDataItem_title'>{$record->_title}</a>
							</div>
							<div class='ipsType_break ipsContained'>
								<a href="{$record->url()->setQueryString( 'do', 'getLastComment' )}" title='{lang="view_this_cmsrecord" sprintf="\IPS\Member::loggedIn()->language()->addToStack( 'content_db_lang_sl_' . $record::$customDatabaseId, FALSE ), $record->_title"}' class='ipsDataItem_title'>{$record->customFieldDisplayByKey('lien-image-pour-forum')|raw}</a>
							</div>
					</li>
             	 {{endif}}
				{{endforeach}}
			</ul>
		</div>
{{endif}}

The first thing I would like to know is :

- how to know the number of item in "$records" ? In another way than doing :

{{$Count = 0;}}

 {{foreach $records as $record}}

{{$Count = $Count+1;}}

{{endforeach}}

 

Then ; is their any way of accessing a specific result ?  Like the third item ?

last question : do you know any random function ? or do we have to use the rand(x,y) function from HTML ?

 

Thanks a lot for your help !

Posted

THanks to you I achieve to do what i wanted :

<div class='ipsPad_half ipsWidget_inner'>
            <ul class='ipsDataList  ipsContained_container'>
              {{shuffle($records);}}
              {{ $record = $records[0];}}

                    <li class='ipsDataItem'>
                      <div class='ipsType_break ipsContained'>
                                <a href="{$record->url()->setQueryString( 'do', 'getLastComment' )}" title='{lang="view_this_cmsrecord" sprintf="\IPS\Member::loggedIn()->language()->addToStack( 'content_db_lang_sl_' . $record::$customDatabaseId, FALSE ), $record->_title"}' class='ipsDataItem_title'>{$record->_title}</a>
                            </div>
                            <div class='ipsType_break ipsContained'>
                                <a href="{$record->url()->setQueryString( 'do', 'getLastComment' )}" title='{lang="view_this_cmsrecord" sprintf="\IPS\Member::loggedIn()->language()->addToStack( 'content_db_lang_sl_' . $record::$customDatabaseId, FALSE ), $record->_title"}' class='ipsDataItem_title'>{$record->customFieldDisplayByKey('lien-image-pour-forum')|raw}</a>
                            </div>
                          <div> <a href="https://www.1001bd.com/best_of/">Voir l'integralité des  best of </a></div>
                    </li>

            </ul>
        </div>

Like that each time someone connect the selection is different.

 

Better thing would to have it change automatically after 1 minutes. Can we do that sort of thing without reloading the page ?

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...