Support ⇒ Requests :: Archives ⇒ Calling blocks from CPG Main Menu :: Archived ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexRequests

Archived ⇒ Calling blocks from CPG Main Menu


I have been trying to include calls to certain Dragonfly blocks that don't have associated modules. For instance, I would like to keep the front page as clear of blocks as possible, but still be able to call, say, Newsletter or Language from the menu. Perhaps this just isn't possible or I have missed a bit of documentation somewhere. Your collective intellect on this little problem would be greatly appreciated.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Hosted


You are right in that you cannot do this.
You might like to look at biggles blocks www.dragonflycms.org/F...13036.html which lets you assign blocks to different modules.

It would however be very easy to write a module to display block files. You would only need one file in the module directory - something like this:

modulesname: blockdisplay
index.php :
<?php
if (!defined('CPG_NUKE')) { exit; }
if (isset($_GET['blockfile'])){
$blockfile = $_GET['blockfile'];
require_once("blocks/".$blockfile.".php");
}else{
echo ("No block filename supplied");
}
?>

Then you would call this in the main menu with a getlink like this:
blockdisplay&blockfile=blockfilename

Hope this helps.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux//4.0.27/4.4.2/9.0.6.1


You could add file_exists like this

if (!defined('CPG_NUKE')) { exit; } if (isset($_GET['blockfile']) && file_exists("blocks/".$_GET['blockfile'].".php")){ $blockfile = $_GET['blockfile']; require_once("blocks/".$blockfile.".php"); }else{ echo ("No block filename supplied"); }

Firefox is my Favorite Browser

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Apache/1.3.34 (Unix)/4.0.25-standard/4.4.1/CVS


OK it works, here is my final code. Thanks for all the help, guys.
<?php /********************************************* CPG Dragonfly CMS ******************************************** Copyright  ? 2004 - 2005 by CPG-Nuke Dev Team www.dragonflycms.com This module cobbled together by Peter Driskell Based entirely on the work of dcollis and xfsunoles Dragonfly is released under the terms and conditions of the GNU GPL version 2 or any later version **********************************************/ if (!defined('CPG_NUKE')) { exit; } if (isset($_GET['blockfile']) && file_exists("blocks/".$_GET['blockfile'].".php")){ $blockfile = $_GET['blockfile']; require_once("blocks/".$blockfile.".php"); }else{ echo ("No block filename supplied"); } // there's probably a better way to render a block - but this works require_once('header.php'); OpenTable(); echo '<div>'."\n"; echo $content."\n"; CloseTable(); echo '</div>'."\n"; ?>

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Hosted


hehe, oops. I forgot about the echo'ing $content. (which is pretty rediculous as thats what i've been working on for the last month : dev.fivemind.co.uk/Per...gner3.html )

Your closetable should be outside the </div> thought shoudn't it? (or the opentable should be inside).

You could also do
<div class="table1> stuff </div>
And finally, you could set the $pagetitle variable to set the header to whatever name you want. (maybe = $blockfile)

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux//4.0.27/4.4.2/9.0.6.1


OK - looks better and better - wish I could claim the credit for this clever module. Thanks to one and all. Here, once again is the latest (probably not the final) version of the code.
<?php /********************************************* CPG Dragonfly CMS ******************************************** Copyright ? 2004 - 2005 by CPG-Nuke Dev Team www.dragonflycms.com This module cobbled together by Peter Driskell Based entirely on the work of DCOLLIS and XFSUNOLES Dragonfly is released under the terms and conditions of the GNU GPL version 2 or any later version Usage : getlink BlockDisplay&blockfile=abcd where abcd is the name of the block Example - to display block-Newsletter.php getlink BlockDisplay&blockfile=Newsletter **********************************************/ if (!defined('CPG_NUKE')) { exit; } if (isset($_GET['blockfile']) && file_exists("blocks/block-".$_GET['blockfile'].".php")){ $blockfile = $_GET['blockfile']; require_once("blocks/block-".$blockfile.".php"); }else{ echo ("Block filename missing or incorrect - leading 'block-' not needed."); } require_once('header.php'); echo '<div class="blockheadl">'.$blockfile.'</div>'; echo '<div class="table1">'."\n"; echo $content."\n"; echo '</div>'."\n"; ?>

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Hosted


Nice one.
Suggest you .zip it up and add it to the downloads section if you get a chance.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux//4.0.27/4.4.2/9.0.6.1


just thought, for the purposes of people reading this site I should link to this topic: (sticky in modules + blocks), which actually talks about something similar dragonflycms.org/Forum...16395.html

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux//4.0.27/4.4.2/9.0.6.1


i see a bug...

if echo ("Block filename missing or incorrect - leading 'block-' not needed."); is executed then its causing problem..
if (!defined('CPG_NUKE')) { exit; } require_once('header.php'); if (isset($_GET['blockfile']) && file_exists("blocks/block-".$_GET['blockfile'].".php")){ $blockfile = $_GET['blockfile']; require_once("blocks/block-".$blockfile.".php"); echo '<div class="blockheadl">'.$blockfile.'</div><div class="table1">'."\n"; echo $content."\n"; echo '</div>'."\n"; }else{ echo "Block filename missing or incorrect - leading 'block-' not needed."; }

Firefox is my Favorite Browser

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Apache/1.3.34 (Unix)/4.0.25-standard/4.4.1/CVS


Floor laughing I've only been in the progamming business for 30 years - what-a mistake-a to make-a!!!

I think i'll just have a lie down and use your code.

Thanks for all your help, as ever.

I will zip it as suggested.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Hosted

All times are UTC
This forum is locked: you cannot post, reply to, or edit topics. Forum IndexRequests
Page 1 of 1