<div id="tabs"> <ul><li><a href="[[~65? &searChar=`A`]]">A | </a></li> <li><a href="[[~65? &searChar=`B`]]">B | </a></li> ....
[[!getResources:default=`<div style="padding: 10px 0 10px 50px;">Sorry - no books here</div>`? &parents=`66` &tpl=`ajaxTabTmp` &includeTVs=`1` &processTVs=`1` &sortdir=`ASC` &sortby=`menuindex` &limit=`9999` &tvFilters=`title==[[!getURLparam]]%` ]]
<?php $output = ''; $output .= $_GET['searChar']; return $output;
<div class="felder">
<a href="[[~[[+tv.ID]]]]" titel="[[+tv.title]]">
<img id="felder" src="[[+tv.titleImg:phpthumbof=`w=120&h=169&zc=1`]]" height="169" width="120" alt="">
</a>
<div class="feldertext">
<a href="[[~[[+tv.ID]]]]" titel="[[+tv.title]]"><div class="uber">[[+tv.title]] </div></a>
<div class="unter"><a href="[[*site_url]]/authors/[[getResourceField? &id=`[[+tv.authorFirst]]` &field=`alias`]].html">[[getResourceField? &id=`[[+tv.authorFirst]]`]]</div></a>
<div class="hyphenate text" lang="de">[[+tv.contentDescription:wordTrunc=`100`]]</div></br>
<!--[[+tv.newBooks]]-->
</div>
<div class="preis">Preis: € [[+tv.book_EUR]] <a class="kaufen" href="[[~[[+tv.ID]]]]">Kaufen</a>
</div>
</div>
, but it's slow. I should probably write a xPDO snippet that builds everything together instead of using getResource and getResourceField. But my php knowledge is limited. How could I make this code efficient. How could I optimize caching.<?php
$output = '';
$_GET['searChar'] = str_replace('>','',$_GET['searChar']);
$_GET['searChar'] = str_replace('<','',$_GET['searChar']);
$searChar .= $_GET['searChar'];
/*echo $searChar;*/
$path = MODX_CORE_PATH . 'components/store/';
$result = $modx->addPackage('store',$path . 'model/','zambon_');
if (! $result) {
return 'failed to add package - Yuck - please contact us at the contact page siteadmin@****.net';
} else {
$output = '';
$books = $modx->getCollection('Store', array(
'title:LIKE' => '$searChar%'
));
foreach($books as $book) {
$fields = $book->toArray();
$output .= $modx->getChunk('ShowAll', $fields);
}
return $output;
}
'title:LIKE' => $searChar . '%'
.'title:LIKE' => $searChar . '%'
select all books which have the same authorfield like book with the id="4"
select * from store where authorFirst in (select authorFirst from store where id="4")
<?php
$output = '';
$bookid .= $_GET['bookid'];
/*echo $bookid;*/
$path = MODX_CORE_PATH . 'components/store/';
$result = $modx->addPackage('store',$path . 'model/','zambon_');
if (! $result) {
return 'failed to add package - Yuck - please contact us at the contact page';
} else {
/*select * from zambon_store where authorFirst in (select authorFirst from zambon_store where id="4")*/
$query = 'SELECT * FROM zambon_store WHERE authorFirst in (select authorFirst from zambon_store where id="'.$bookid.'")';
$criteria = new xPDOCriteria($modx, $query);
$books = $modx->getCollection('Store', $criteria);
foreach($books as $book) {
$fields = $book->toArray();
$output .= $modx->getChunk('ShowAllTmp', $fields);
}
return $output;
}