after knocking my head on this for nearly a week, I cannot for the life of me figure out what I'm doing wrong, which class I need to extend (and/or decorate), whether I am to use view, model, or controller .. there doesn't seem to be any detailed information anywhere of anyone else trying this for me to build my ideas on, and I don't yet have enough basic knowledge of x-cart 5's functionality despite all the tutorials due to their un-fleshed-out nature.
I created classes/XLite/Module/MY-ID/MY-MODULE/View/Page.php and added the following
Code:
<?php
// vim: set ts=4 sw=4 sts=4 et ft=php.html:
namespace XLite\Module\MHG\TemplateMods\View;
class Page extends \Xlite\View\AView implements \XLite\Base\IDecorator
{
public static function getAllowedTargets()
{
return array_merge(parent::getAllowedTargets(), array('page'));
}
public function getCSSFiles()
{
$css = parent::getCSSFiles();
// find page id by its name
// $cnd is an object containing the condition for "page name is equal to ..." and if this search
// condition does not exist in the Repo class you have to create it as well for this to work
$cnd = new \Xlite\Core\CommonCell();
$cnd->enabled = true;
$cnd->name = "Photo Gallery";
$current_id = \XLite\Core\Request::getInstance()->id;
$target_id = \XLite\Core\Database::getRepo('XLite\Module\CDev\SimpleCMS\Model\Page')->search($cnd);
\XLite\Logger::logCustom('MHG', "currentID: {$current_id} targetID: {$target_id}\n", true);
//error_log("currentID: {$current_id} targetID: {$target_id}\n");
if ( $target_id == $current_id )
{
$css = array_merge(
$css,
array(
'url' => "//cdnjs.cloudflare.com/ajax/libs/nanogallery/5.3.0/css/nanogallery.min.css",
'no_minify' => true,
),
array(
'url' => "//cdnjs.cloudflare.com/ajax/libs/nanogallery/5.3.0/css/themes/light/nanogallery_light.min.css",
'no_minify' => true,
),
// see also https://cdnjs.cloudflare.com/ajax/libs/nanogallery/5.3.0/jquery.nanogallery.min.js for javascript related to this
)
);
}
return $css;
}
protected function getDefaultTemplate()
{
return 'modules/CDev/SimpleCMS/page/body.tpl';
}
}
even if $cnd is wrong, AND there is no search functionality in this for the Repo, I should STILL get a log of the current page ID and don't get that either.
where am I going so totally wrong?