PDA

View Full Version : How to create a custom CMS page


Sadikb
11-21-2010, 11:52 AM
Hi,

I know there's the PHP Direct Evaluation Content Type, but the content / article one can create with it remains under the cms section. That is, the url will be content.php?... etc.

I want a separate php page, something like www.mysite.com/mypage.php

On this php page I want to display CMS widgets. Now I can create a custom page and display VB Header, navbar, footer just fine using this article (https://vborg.vbsupport.ru/showthread.php?t=228112) as a reference point, but obviously I won't be able to display the CMS widgets in this, or can I? if yes, how? if no, is there any way?

Thanks for reading...

Alfa1
11-21-2010, 12:22 PM
The CMS seems to lack any flexibility or functionality in this regard at this time.

Sadikb
11-22-2010, 04:24 AM
Hi Alfa,

I found a way, but i am still testing. I will hopefully paste the code if I am able to achieve this.

FReeSTER
11-23-2010, 02:49 PM
I will follow up on this, I will love to do the same but Im bad with variables. Im trying to archive a page like this one here http://www.minatica.be/content/
but I have no clue where to start from. I seen many sites getting this done but unfortunately for me is not the case.

Sadikb
11-25-2010, 05:20 PM
Actually I gave up on the idea as it was too much work and I had little time. But it can be done. This is how to do it,

The following is code of a sample custom page, which has the VB header, navbar and footer and CMS Widgets as it's main content. The page is far from finished, like I said I abondoned the idea of implementing this. I am sharing the code so that if someone else wants to do this he has a starting point.


<?

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT', 'test');
define('CSRF_PROTECTION', true);
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('TEST',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

$navbits = construct_navbits(array('' => 'Test Page'));
$navbar = render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'My Page Title';


// ##### INCLUDE WIDGETS #####

require_once('./includes/class_bootstrap_framework.php');
vB_Bootstrap_Framework::init();
vBCms_View_Widget::registerTemplater(vB_View::OT_X HTML, new vB_Templater_vB());

$widgetID = 27; // the id of the widget, this you can get from the CMS_WIDGET table

$widgettype = 'RecentArticle'; // type of the widget you want to output, this is the Class Name, you can get this from packages/vbcms/widget folder. The file names are usually the same as classnames

$widget = vBCms_Widget::create('vBCms', $widgettype, $widgetID);
$output = $widget->getPageView()->render();

// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('widget', $output);
print_output($templater->render());


?>

You will obviously run into styling issues as your widget css would not be available for the custom page, but i didn't spend time on that.

--------------- Added 1290712997 at 1290712997 ---------------

I will follow up on this, I will love to do the same but Im bad with variables. Im trying to archive a page like this one here http://www.minatica.be/content/
but I have no clue where to start from. I seen many sites getting this done but unfortunately for me is not the case.

That's RS_Jelle's site. He's a very talented coder (Downloads II)... :)

SkyStryder
04-13-2011, 02:01 PM
The widgets do work in this example. Does anyone know how to
intialize {vb:raw layout}? That would be the next step which I am
trying to work out now.

Thank you!
Rick

wheretobet
04-18-2011, 02:28 AM
Why raw layout?

Shouldn't it be {vb:raw output}

I have tested this but I don't see that cms widgets work on custom pages

Disasterpiece
04-19-2011, 07:51 AM
If it's just for the url's sake, you can create a url rewrite in your .htaccess so http://whatever.tld/foo.php
directs to http://whatever.tld/content.php?id=9001
it's actually pretty easy if you google it up (try "url rewrite htaccess")
this would spare you the hacking/coding and you'd keep the benefits of the vbcms like editor, modifyable site, etc.