function smt_block_list($catid, $maincat = '<ul>%s</ul>', $subcat = '<div style="margin-left:10px;">%s</div>', $header = '<h3 style="margin:2px 0;">%s</h3>', $subheader = '<h5 style="margin:2px 0;">%s</h5>', $block = '<li style="margin-left:0;">%s</li>', $blockheader = true) { if (isset($_GET['s'])) { $id = (int) $_GET['s']; return smt_block_content($id, $blockheader); } $html = NULL; $maincat = explode('%s', $maincat); $subcat = explode('%s', $subcat); $header = explode('%s', $header); $subheader = explode('%s', $subheader); $block = explode('%s', $block); $catid = (int) $catid; $ask = mysql_query("SELECT block_id, block_title, block_show, setting_name, setting_value, setting_id FROM `blocks` RIGHT JOIN settings ON blocks.block_cat = settings.setting_id WHERE settings.setting_owner = 'block_category' AND (setting_value = '{$catid}' OR setting_value LIKE '{$catid},%') AND block_show=1 ORDER BY setting_value ASC, block_order ASC"); $lastcat = NULL; $anacat = NULL; $bid = 0; while ($blck = mysql_fetch_assoc($ask)) { $curanacat = explode(',', $blck["setting_value"]); $curanacat = $curanacat[0]; if ($blck["setting_id"] !== $lastcat) { if (in_array($anacat, explode(',', $blck["setting_value"]))) { // is this subcat? for ($i = 0; $i < $lastcatcount - (count(explode(',', $blck["setting_value"])) - 1); $i++) { $html .= $subcat[1]; } $html .= $subcat[0]; } else { if ($bid !== 0) { for ($i = 0; $i <= substr_count($lastvalue, ','); $i++) { $html .= $main[1]; } } } $html .= $subheader[0] . $blck["setting_name"] . $subheader[1]; $html .= $maincat[0]; } if ($blck["block_id"] !== NULL) { $html .= $block[0]; $html .= '<a href="?s=' . $blck["block_id"] . '">' . $blck["block_title"] . '</a>'; $html .= $block[1]; } $anacat = explode(',', $blck["setting_value"]); $anacat = $anacat[0]; $lastvalue = $blck["setting_value"]; $lastcat = $blck["setting_id"]; $lastcatcount = count(explode(',', $blck["setting_value"])); $bid++; } echo $html; }
<?php smt_get('header'); ?> <div id="content-container"> <div id="container"> <h1>Merhaba Burası Anasayfa!</h1> <h2>İstediğini Koy Buraya!</h2> <div style="width:33%; float:left;"> <?php smt_block_content('Referanslar', TRUE, '300'); ?> </div> <div style="width:33%; float:left;"> <?php smt_block_content('Referanslar', TRUE, '300'); ?> </div> <div style="width:33%; float:left;"> <?php smt_block_content('Referanslar', TRUE, '300'); ?> </div> </div> <?php smt_get('footer');