Sycnonising random() order Listviews (resolved)

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Sycnonising random() order Listviews (resolved)

Beitragvon Michael_S » Sa 21. Mai 2011, 21:30

Is there a way of sycnonising two listviews on the same page when using a random() order? The first listview is a JQueryTools slider and the second listview is the sliders navigation.

I assume I can do this with objects but would like to use documents

Thanks in advance,

Michael.
Zuletzt geändert von Michael_S am So 22. Mai 2011, 13:50, insgesamt 1-mal geändert.
Production Area
London, UK
http://productionarea.com

Creutzburg
Senior Member
Beiträge: 425
Registriert: Do 1. Jan 1970, 02:00
Wohnort: Dresden
Kontaktdaten:

Re: Sycnonising random() order Listviews

Beitragvon Creutzburg » Sa 21. Mai 2011, 22:12

You could do this by storing the output of the random listview in a PHP array. Doing this, you can echo your randomized listview as often as you want.

Let me know if you need further assistance.

Regards,
Alex
http://www.xport.de – Internet-Agentur für Hotels
http://www.domainpreisvergleich.de – Domain-Preisvergleich inkl. Verfügbarkeits-Check – ist meine Wunschdomain noch frei, und wo registriere ich sie am günstigsten?

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Sycnonising random() order Listviews

Beitragvon Michael_S » Sa 21. Mai 2011, 22:39

Hi Alex,

That makes sense, I've had a look through the forum but can't find a reference could you help me with a code example. Also would this work with both listview type document and object?

Thanks,

Michael.
Production Area
London, UK
http://productionarea.com

Creutzburg
Senior Member
Beiträge: 425
Registriert: Do 1. Jan 1970, 02:00
Wohnort: Dresden
Kontaktdaten:

Re: Sycnonising random() order Listviews

Beitragvon Creutzburg » Sa 21. Mai 2011, 23:01

Hi Michael,

it doesn't matter if you use it for a document or object listview.

Try this for storing your listview in an array:

Code: Alles auswählen

<?php
$myCounter = 0;
?>
<we:listview name="xyz" type="document" order="random()">
<we:repeat>
<?php
$myArray[$myCounter]["title"] = $lv->f("title"); // let's say you have a field "title" in your listview documents
$myArray[$myCounter]["content"] = $lv->f("content"); // let's say you have a field "title" in your listview documents
$myCounter++;
?>
</we:repeat>
</we:listview>




Now you can echo your listview as you like:

Code: Alles auswählen

<?php
foreach ($myArray AS $key => $value) {
  echo $value["title"]; // echoes the title field
}

foreach ($myArray AS $key => $value) {
  echo $value["content"]; // echoes the content field
}

?>


I hope that works for you? You could change the listview type to "object" without any changes. The field names "content" and "title" are examples only.

Regards,
Alex
http://www.xport.de – Internet-Agentur für Hotels
http://www.domainpreisvergleich.de – Domain-Preisvergleich inkl. Verfügbarkeits-Check – ist meine Wunschdomain noch frei, und wo registriere ich sie am günstigsten?

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Sycnonising random() order Listviews

Beitragvon Michael_S » So 22. Mai 2011, 00:18

Hi Alex,

Thanks that was excelent. For anyone else looking at JQueryTools Scrollable (http://flowplayer.org/tools/index.html) here's the basic working code based on Alex's method to output an Object listview as a scroller with navigation. Alex indicated the same method could be used with a document based listview.

My requirement was to have featured (sticky) posts included in the scroller, for this example the sticky posts are tagged using a checkbox.

1. Include JQuery Tools

Code: Alles auswählen

<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>


2. Zero the counter

Code: Alles auswählen

<?php
   $myCounter = 0;
?>


3. Set your Listview condition (Blog_Featured = checkbox)

Code: Alles auswählen

<we:condition name="featured">
   <we:conditionAdd field="Blog_Featured" value="1" compare="=" />
</we:condition>


4. Instigate the listview and count the results

Code: Alles auswählen

<we:listview type="object" name="Featured" order="random()" condition="\$featured" classid="2">
   <we:repeat>
      <?php
         $myArray[$myCounter]["WE_ID"] = $lv->f("WE_ID");
         $myArray[$myCounter]["Blog_Title"] = $lv->f("Blog_Title");
         $myCounter++;
      ?>
   </we:repeat>
</we:listview>


5. Output the Listview array for the scroll panels

Code: Alles auswählen

<div id="scroll">
   <div id="tools">
      <?php
         foreach ($myArray AS $key => $value) {
            echo '<div class="tool" style="background: blue;">';
            echo '<div class="content">';      
            echo '<span class="title">#' . $value["WE_ID"] . '&nbsp;' . $value["Blog_Title"] . '</span>';
            echo '</div>';
            echo '</div>';
         }
      ?>
   </div>
</div>


6. Output the scroll navigation in the same order as the panels

Code: Alles auswählen

<div class="navi">
   <?php
      foreach ($myArray AS $key => $value) {      
         echo '<a class="slider_nav">#' . $value["WE_ID"] . '&nbsp;-&nbsp;' . $value["Blog_Title"] . '</a>';
      }
   ?>
</div>
Production Area
London, UK
http://productionarea.com


Zurück zu „webEdition Basic Version“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast