vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   How to create a custom CMS page (https://vborg.vbsupport.ru/showthread.php?t=254033)

Sadikb 11-21-2010 11:52 AM

How to create a custom CMS page
 
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 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.

PHP Code:

<?

// ####################### 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_XHTML, 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 [DATE]1290712997[/DATE] at [TIME]1290712997[/TIME] ---------------

Quote:

Originally Posted by El Intocable (Post 2125007)
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.


All times are GMT. The time now is 12:57 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01225 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete