Project

General

Profile

« Previous | Next » 

Revision 246

Added by stefan almost 19 years ago

Improved default block content feature. Usage: If a template is used with multiple blocks and a page does not have content in one of the blocks, the content of this block is taken from the default (start) page instead. This behavior can be deactivated by setting ->default_block_content='none' or a specific page can be set using ->default_block_content=%page_id% where page_id stands for the page id of the page to use. This variable can be changed before every page_content call for the specific blocks to allow for complete flexibility.

View differences:

frontend.functions.php
142 142
		if(!is_numeric($block)) { $block = 1; }
143 143
		// Include page content
144 144
		if(!defined('PAGE_CONTENT') OR $block!=1) {
145
			if ($wb->page_id==0) {
145
			$page_id=$wb->page_id;
146
			// First get all sections for this page
147
			$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
148
			// If none were found, check if default content is supposed to be shown
149
			if($query_sections->numRows() == 0) {
146 150
				if ($wb->default_block_content=='none') {
147 151
					return;
148 152
				}
149 153
				if (is_numeric($wb->default_block_content)) {
150 154
					$page_id=$wb->default_block_content;
151 155
				} else {
152
					$page_id=$wb->default_page-id;
156
					$page_id=$wb->default_page_id;
153 157
				}				
154
			} else {
155
				$page_id=$wb->page_id;
156
			}
157
			// First get all sections for this page
158
			$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
159
			if($query_sections->numRows() > 0) {
160
				// Loop through them and include there modules file
161
				while($section = $query_sections->fetchRow()) {
162
					$section_id = $section['section_id'];
163
					$module = $section['module'];
164
					require(WB_PATH.'/modules/'.$module.'/view.php');
158
				$query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '".$page_id."' AND block = '$block' ORDER BY position");
159
				// Still no cotent found? Give it up, there's just nothing to show!
160
				if($query_sections->numRows() == 0) {
161
					return;
165 162
				}
166 163
			}
164
			// Loop through them and include their module file
165
			while($section = $query_sections->fetchRow()) {
166
				$section_id = $section['section_id'];
167
				$module = $section['module'];
168
				require(WB_PATH.'/modules/'.$module.'/view.php');
169
			}
167 170
		} else {
168 171
			require(PAGE_CONTENT);
169 172
		}

Also available in: Unified diff