Thanx,
Continue a this way:
Quote from: sottwell at Dec 18, 2014, 05:52 AM
You could have one resource for each business card, using a template just for these resources. A number of TVs would be associated with this "card" template to provide the extra fields for the "card" resource , so when editing each "card" resource you would get the TVs to fill out for that "card". Cards could be displayed individually as a separate web page, or in a gallery on a "Cards" page using a listing snippet like getResources with links to the individual card's page. The individual card page could have more information than what is shown in the gallery of cards.
So ok, I will describe the architecture I have developed.
For example I have several cards. They are preview information of shopping mall lessees.
The number of the cards depends on search results (people find lessees by goods, listed in description) . The fields of each card: phone, address, description and logo. Phone, address, description are child resources of the card resource. Card doesn't have a template, it is created by mixing php and html. I have no problems with phone, address, description.
Сard resources belong to one template. Created TV variable also belong to that template. How will link definite resource with definite TV?
The code:
$counter = 0;
for ($i = 1; $i <= $modx->getCount('modResource'); $i++)
{
$childIDs = $modx->getChildIds($i, 1, array('context' => 'web'));
if ($childIDs[0] != null) // если есть потомок
{
//echo '||| ',$childIDs[0];
foreach ($childIDs as $childID)
{
//echo $modx->getObject('modResource', $childID)->get('description');
if ($modx->getObject('modResource', $childID)->get('pagetitle') == 'что продаётся'){
$whatIsSelling = $modx->getObject('modResource', $childID)->get('description');
}
if ($modx->getObject('modResource', $childID)->get('pagetitle') == 'контакты'){
$contacts = $modx->getObject('modResource', $childID)->get('description');
}
if ($modx->getObject('modResource', $childID)->get('pagetitle') == 'график работы'){
$schedule = $modx->getObject('modResource', $childID)->get('description');
}
}
echo
'<div class="card">
<a href=""><img src="http://localhost/manager/templates/muravey/img/apelsin.gif" width="200px"></a>
<h2>Что продаётся</h2>
<p>',$whatIsSelling,'</p>
<h2 class="card_thin">Контакты</h2>
<h2 class="card_thin">График </h2>
<div style="clear: both;"></div>
<p class="card_thin">',$contacts,'</p>
<p class="card_thin">',$schedule,'</p>
<div style="clear: both;"></div>
</div>';
$counter++;
if ($counter == 4){
$counter = 0;
echo '
<div style="clear: both;"></div>
<hr><a href="" class="to_pictures">расположение магазинов в торговом центре</a>';
}
}
}