You can always download an item in the on-demand category by reporting this from the controller. For example:
Within Controller Action: $this->set('elementPath', "directory_name/$categoryName");
Within the View (this can also be tried exactly within a Layout): <?php if (!empty($elementPath)) { // you can also set a default $elementPath somewhere else, just in case echo $this->element($elementPath); } ?>
In fact, there are other ways to achieve this. If the element is loaded into the layout, the set () method shown above can be specified from the view itself. Or you can even extract it from url parameters, for example:
Within the View or Layout: <?php $elementPath = $this->params['url']['category'];
Of course, you always need to specify, but the same thing would be to check if the file exists.
Yomorales
source share