Poseidon2 Posted July 23, 2020 Posted July 23, 2020 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 !
Meddysong Posted July 23, 2020 Posted July 23, 2020 31 minutes ago, Poseidon2 said: last question : do you know any random function ? or do we have to use the rand(x,y) function from HTML ? I can't help with your other questions but I know that {{shuffle($rows);}} works with database categories when ordering records randomly. You might be able to adapt that for $records rather than $rows. Poseidon2 1
Poseidon2 Posted July 23, 2020 Author Posted July 23, 2020 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 ? Meddysong 1
Adriano Faria Posted July 23, 2020 Posted July 23, 2020 3 minutes ago, Poseidon2 said: Better thing would to have it change automatically after 1 minutes. Can we do that sort of thing without reloading the page ? You would have to use Ajax to accomplish that. I have no idea how you would do that only with a block. You could also take a look in some Jquery ticker, like https://www.jqueryscript.net/tags.php?/news ticker/ Poseidon2 1
Recommended Posts