Forum
perch_content_create problem
Can you spot why the following code works fine on a Perch V2.8 site but outputs no html at all on 3.0.10 site?
<?php
perch_content_create('Horses', array(
'page' => '/horses2.php',
'template' => 'horse_product_detail.html',
'multiple' => true,
'edit-mode' => 'listdetail',
));
if (perch_get('s')) {
// Detail mode
$result = perch_content_custom('Horses', array(
'template' => 'horse_product_detail.html',
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('s'),
'count' => 1,
'skip-template' => true,
'return-html' => true,
));
echo $result['html'];
perch_content_custom('Horses', array(
'template' => 'product_prevnext.html',
'filter' => '_order',
'match' => 'gt',
'value' => $result[0]['_sortvalue'],
'sort' => '_order',
'sort-order' => 'ASC',
'count' => 1,
));
PerchSystem::set_var('is_prev', true);
perch_content_custom('Horses', array(
'template' => 'product_prevnext.html',
'filter' => '_order',
'match' => 'lt',
'value' => $result[0]['_sortvalue'],
'sort' => '_order',
'sort-order' => 'DESC',
'count' => 1,
));
} else {
// List mode
perch_content_custom('Horses', array(
'page' => '/horses2.php',
'template' => 'horse_product_listing.html',
'sort' => 'title',
));
}
?>
Debug says
Debug Message - Perch 3.0.10
[31] SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
[3] SELECT regionKey, regionHTML FROM perch3_content_regions WHERE regionPage='/horses2.php' OR regionPage='*' ORDER BY regionPage DESC
[1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch3_content_regions WHERE regionKey='Horses' AND (regionPage='horses2.php' OR regionPage='*')
[nil] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch3_content_index idx JOIN perch3_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch3_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='title' WHERE ((idx.regionID=5 AND idx.itemRev=22)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval, regionID ORDER BY sortval ASC
Using template: /templates/content/horse_product_listing.html
Do the two share the same data?
No shared data. Templates etc and type of data is similar for two clients with same requirements. System works great for 'older' client (on v2.8). Newer client I used latest V3 but really that is the only difference.
From debug in perch edit area, is this the problem? 'Form not posted or did not validate' After editing, admin tells me content updated correctly. Using template horse_product_detail.html shown below debug
template in question
The two should work in the same way.
and yet they do not! Nothing jumps out at you from debug then, that looks 'normal'?
Yes, it looks fine to me. What are you attempting to do here? Why do you need the same code to work with two versions?
two different clients, two different websites, sharing same need for display of similar data. First client still on V2 perch, new client on V3 perch. think I will go back to v2 for new client too maybe.
SOLVED, found errant code, sorting on wrong field
Sorry for wild goose chase Drew you can mark this as solved and get on with some real problems