Bendensin Posted August 24, 2018 Posted August 24, 2018 I'm creating a guides system for Turkey, where each category of guides, and also certain page themselves, will have their own custom blocks. I am assuming I will have to use hard folders and different page templates for this, but I am not sure. Let me explain with a proposed folder structure. turkeycentral.com/guides: This category (and associated database) has all guides about Turkey. Including guides about places and also provinces and cities and towns. So there would be subcategories like: /guides/residence permits//guides/transportation//guides/places/ The last one, places, is about the provinces and cities. Antalya is a province in Turkey. And Alanya is a city in Antalya province. So under that would be /guides/places/antalya//guides/places/antalya/alanya/ Under that level would be articles about Alanya's local attractions, hotels, beaches, etc. /guides/places/antalya/alanya/attractions/guides/places/antalya/alanya/hotels/guides/places/antalya/alanya/beaches For various categories and pages in this hierarchy, I would like to have blocks with subject-specific advertisements, a block feeding from the Alanya category of a business directory, and on all pages about Alanya, a sub-navigation menu. So it would be as if /guides/places/antalya/alanya/ is its own website, independent from the other categories about other topics and other provinces and towns. And many pages at the same level in the hierarchy would have different custom blocks. So "attractions," "hotels" and "beaches" would each have different custom blocks being displayed on them. So here is my question: From what I am seeing so far, to have different custom blocks on various pages, I cannot just feed from the database directly for this, and I would need to set up hard folders and pages in a completely different hierarchy, then feed the content for those pages from the database onto those pages. Is that correct?
Joel R Posted August 26, 2018 Posted August 26, 2018 That's correct. A database only has 3 templates / views: The record view The listing view The category view So the same block would show on ALL record view, since all record views use the same template. There might be ways for you to filter block information to be relational, so it only shows Alanya while in the Alanya category. You can check out Pages Sidebar by @Fosters, which allows some difference between categories. The control and granularity that you desire is only possible if you create a new IP.Pages page for each page, customized with it's own advertisement, blocks, and database feed. If you do that, you might as well completely skip databases and just create single pages (which is kind of crazy). You seem to have a very ambitious project.
opentype Posted August 26, 2018 Posted August 26, 2018 On 8/24/2018 at 3:08 PM, Bendensin said: From what I am seeing so far, to have different custom blocks on various pages, I cannot just feed from the database directly for this, and I would need to set up hard folders and pages in a completely different hierarchy, then feed the content for those pages from the database onto those pages. Is that correct? Yes, but don’t do it. Keep the content on one database page and solve the block problem (e.g. as Joel suggested) instead of ripping the database apart just to have different blocks.
Meddysong Posted August 26, 2018 Posted August 26, 2018 It's possible to do (quite a technical) work-around. Here's my site: https://timeofftakeoff.com/ I have a block on the page where a database is displayed: https://timeofftakeoff.com/holidays/ This is a standard record feed and would naturally show on every page of the database. It appears as expected when you click on a category: https://timeofftakeoff.com/holidays/2017/ But it doesn't appear with subcategories (https://timeofftakeoff.com/holidays/2017/france-alps-2017/) or records themselves (https://timeofftakeoff.com/holidays/2017/france-alps-2017/day-8-chamonix/) like you would expect. The reason is because I've made a conditional statement which will include the block only if the first part of the path (the URL after the domain name) is "holidays" and if there are two or fewer parts in that path (ie /holidays and /holidays/category): {database="toto"} {{$pieces = explode('/', \IPS\Request::i()->path);}} {{if $pieces[0] == 'holidays' and count($pieces) <= 2}} {{$block = null; try {$block = \IPS\cms\Blocks\Block::load('our_latest_adventures', 'block_key');} catch(\Exception $e) {} }} {{if $block and \IPS\cms\Blocks\Block::display($block, 'vertical')}} {{\IPS\Output::i()->sidebar['widgets']['sidebar'][] = $block->widget();}} {{endif}} {{endif}} So you could try something built on that approach to target specific blocks for specific pages.
Bendensin Posted August 27, 2018 Author Posted August 27, 2018 Wow. This is very valuable advice for me. Thank you Joel R, Opentype, and Meddysong for solving this problem, which has been keeping me awake at night! My project looks to be a lot easier now. I am now checking out the Pages Sidebar by @Fosters and it appears to be exactly what I need. I see there is also a Forum Sidebar, so that will be a huge plus.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.