The page template that drives the pageBuilder.php file is pbuilder_cpanel.html.
In this template, you can add buttons next to the Add Column, Add Page and Go buttons. This template also controls how new pages are added.
Here's what it looks like:
<div class="adm-db-control-panel">
<div class="adm-pb-cp-item">
<form name="pageSelector" method="get" action="__url__">
<bx_text:_adm_txt_pb_page />
<select class="form_input_select" name="Page" onchange="if (this.value && this.value != 'none') this.form.submit()">
<bx_repeat:pages>
<option value="__value__" __selected__>__title__</option>
</bx_repeat:pages>
</select>
<input type="submit" value="<bx_text:_adm_btn_Go />" />
</form>
</div>
<div class="adm-pb-cp-item-right">
<div class="button_wrapper">
<input type="button" value="<bx_text:_adm_btn_add_page />" class="form_input_submit" onclick="javascript:createNewBuilderPage()" />
<div class="button_wrapper_close"> </div>
</div>
</div>
<div class="adm-pb-cp-item-right">
<div class="button_wrapper">
<input type="button" value="<bx_text:_adm_btn_add_column />" id="addColumnButton" class="form_input_submit" onclick="javascript:oPB.addColumn()" disabled="disabled" />
<div class="button_wrapper_close"> </div>
</div>
</div>
<div class="clear_both"> </div>
<script type="text/javascript" language="javascript">
<!--
function createNewBuilderPage() {
var sNewPage = prompt('<bx_text:_adm_txt_pb_enter_name_of_new_page />', 'New Page');
if(sNewPage != undefined && $.trim(sNewPage) != '')
window.location = '__url__?create_new=true&Page=' + encodeURIComponent( sNewPage );
}
-->
</script>
</div>
This part will list the pages that are available for editing:
<bx_repeat:pages>
<option value="__value__" __selected__>__title__</option>
</bx_repeat:pages>
You notice the keys being used. Those are derived from the following:
[more info about keys and tokens in d7 and how they differ from d6]
This part will allow you to add a button to the top of the page. You can use this as a starting template:
<div class="adm-pb-cp-item-right">
<div class="button_wrapper">
<input type="button" value="<bx_text:_adm_btn_add_page />" class="form_input_submit" onclick="javascript:createNewBuilderPage()" />
<div class="button_wrapper_close"> </div>
</div>
</div>
Notice the onClick JavaScript. Further down it calls the following function:
<script type="text/javascript" language="javascript">
<!--
function createNewBuilderPage() {
var sNewPage = prompt('<bx_text:_adm_txt_pb_enter_name_of_new_page />', 'New Page');
if(sNewPage != undefined && $.trim(sNewPage) != '')
window.location = '__url__?create_new=true&Page=' + encodeURIComponent( sNewPage );
}
-->
</script>
You can use this same approach to add an action to you any button you add. For example, let's say we wanted to add a Delete button. Before, you can just drag out the contents of the page in page builder and the page would automatically disappear. For Dolphin 7, we have to detete directory from the database.
Before we can delete a page, we have to understand how exactly a page is created via the admin panel and in the backend. So here are my notes:
1. In Page Builder click the Add Page button.
2. A dialog box appears where you can enter the name of your page.
3. Once you hit the OK button, a series of actions take place, The first being the function createNewBuilderPage() is fired. It then passes a querystring containing two values. They are:
create_new=true&Page=' + encodeURIComponent( sNewPage );
The name/value pair create_new=true just tells the action page the mode that we're going to use. In this case, we want to creat a new page, hence the true value.
The Page name/value pair first encodes the page name that was entered so it's a form that we can pass over to the action page.
In my example, I used "James Test Page" to create a page. When it hits the action page it adds an entry in the following tables:
sys_page_compose_pages - Fields list: Name, Title, Order, System
Once you add a column and content, a new entry is made in the following table:
sys_page_compose - Fields list: ID, Page, PageWidth, Desc, Caption, Column, Order, Func, Content, DesignBox, ColWidth, Visible, MinWidth
In effect, James-Test-Page becomes the name of the page within the database. That would be the name you would reference when you need to delete the page.
If we were to do a search for "James-Test-Page" it will pull up the tables
sys_page_compose
sys_page_compose_pages
This makes sense as it should match the tables where the page entries were made.
Now that we know how pages are made, we now know what parts of the tables we need to work with in order delete a page.
HOW TO DELETE A PAGE
Earlier we looked at how pages were made. The action page used for adding pages is called:
BxDolPageViewAdmin.php
It's located in the inc/classes folder.
This page takes the passed values and then manipulates the database. It's activated when the Add Page button is pressed which then fires the function createNewBuilderPage(). That function, remember looks like this:
function createNewBuilderPage() {
var sNewPage = prompt('<bx_text:_adm_txt_pb_enter_name_of_new_page />', 'New Page');
if(sNewPage != undefined && $.trim(sNewPage) != '')
window.location = '__url__?create_new=true&Page=' + encodeURIComponent( sNewPage );
}
So what we need to do is to add a delete page action? See below.
---
Here's the complete code for the pbuilder_cpanel.html page:
<div class="adm-db-control-panel">
<div class="adm-pb-cp-item">
<form name="pageSelector" method="get" action="__url__">
<bx_text:_adm_txt_pb_page />
<select id="pageValue" class="form_input_select" name="Page" onchange="if (this.value && this.value != 'none') this.form.submit()">
<bx_repeat:pages>
<option value="__value__" __selected__>__title__</option>
</bx_repeat:pages>
</select>
<input type="submit" value="<bx_text:_adm_btn_Go />" />
</form>
</div>
<div class="adm-pb-cp-item-right">
<div class="button_wrapper">
<input type="button" value="Delete This Page" class="form_input_submit" onclick="javascript:deleteCurrentPage()" />
<div class="button_wrapper_close"> </div>
</div>
</div>
<div class="adm-pb-cp-item-right">
<div class="button_wrapper">
<input type="button" value="<bx_text:_adm_btn_add_page />" class="form_input_submit" onclick="javascript:createNewBuilderPage()" />
<div class="button_wrapper_close"> </div>
</div>
</div>
<div class="adm-pb-cp-item-right">
<div class="button_wrapper">
<input type="button" value="<bx_text:_adm_btn_add_column />" id="addColumnButton" class="form_input_submit" onclick="javascript:oPB.addColumn()" disabled="disabled" />
<div class="button_wrapper_close"> </div>
</div>
</div>
<div class="clear_both"> </div>
<script type="text/javascript" language="javascript">
<!--
function createNewBuilderPage() {
var sNewPage = prompt('<bx_text:_adm_txt_pb_enter_name_of_new_page />', 'New Page');
if(sNewPage != undefined && $.trim(sNewPage) != '')
window.location = '__url__?create_new=true&Page=' + encodeURIComponent( sNewPage );
}
function deleteCurrentPage() {
page2Delete = document.getElementById("pageValue").value;
window.location = '__url__?delete_page=true&Page=' + page2Delete;
}
-->
</script>
</div>
Here's where you put the code for the BxDolPageViewAdmin.php file:
<?php
/***************************************************************************
* Dolphin Smart Community Builder
* -------------------
* begin : Mon Mar 23 2006
* copyright : (C) 2007 BoonEx Group
* website : http://www.boonex.com
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the
* License, or any later version.
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/
require_once( BX_DIRECTORY_PATH_ROOT . 'plugins/Services_JSON.php' );
class BxDolPageViewAdmin {
var $aPages = array();
var $oPage;
var $sPage_db; //name of current page, used form database manipulations
var $sDBTable; //used database table
var $bAjaxMode = false;
var $aTitles; // array containing aliases of pages
function BxDolPageViewAdmin( $sDBTable, $sCacheFile ) {
//jt note - Delete Page START --------------------------------------------------------------------//
if ($_GET['delete_page'] == 'true') {
//set up connection to MySql server
$jt_dbHost = DATABASE_HOST;
$jt_dbLogin = DATABASE_USER;
$jt_dbPass = DATABASE_PASS;
$jt_db = DATABASE_NAME;
//$Name = "Test-Page";
$Name = $_GET['Page'];
$connection=mysql_connect("$jt_dbHost","$jt_dbLogin","$jt_dbPass") or die("Couldn't connect to the server.");
//select the database
$db=mysql_select_db("$jt_db", $connection) or die("Couldn't select a database.");
mysql_query("DELETE FROM `sys_page_compose_pages` WHERE `sys_page_compose_pages`.`Name` = '" . $Name . "' LIMIT 1",$connection);
mysql_query("DELETE FROM `sys_page_compose` WHERE `sys_page_compose`.`Page` = '" . $Name . "' LIMIT 1",$connection);
mysql_close($connection);
}
//jt note - Delete Page END --------------------------------------------------------------------//
$GLOBALS['oAdmTemplate']->addJsTranslation(array(
'_adm_pbuilder_Reset_page_warning',
'_adm_pbuilder_Column_non_enough_width_warn',
'_adm_pbuilder_Column_delete_confirmation',
'_adm_pbuilder_Add_column',
'_adm_pbuilder_Want_to_delete'
));
....lots of code below....
Updating my BoonexNerd.net site.