Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 11:09:20 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155556 Posts in 21715 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: give sections a name, display this in edit page screen  (Read 249 times)
Bug

Offline Offline

Posts: 188


« on: November 08, 2011, 12:16:59 PM »

I guess we all have been struggling with this once or twice

sections have no name, with 6 or more wysywyg pages on one page it becomes pretty hard too have a clear view on which section you need to edit sometimes ...

the answer is:

add a tablerow into de db in the sections table

I named it "namesection" (VARCHAR / 255)

in the sections.php i added:
Code:
<input type="text" class="inputveldje" id="namesection<?php echo $section['section_id']; ?>" name="namesection<?php echo $section['section_id']; ?>" value="<?php echo $section['namesection']; ?>" style="width: 100px;" />
   

in the admin/pages/sections_save.php I added changed some lines around line 100

Code:
// update publ_start and publ_end, trying to make use of the strtotime()-features like "next week", "+1 month", ...
if(isset($_POST['start_date'.$section_id]) AND isset($_POST['end_date'.$section_id])) {
if(trim($_POST['start_date'.$section_id]) == '0' OR trim($_POST['start_date'.$section_id]) == '') {
$publ_start = 0;
$namesection = ($_POST['namesection'.$section_id]);
} else {
$publ_start = jscalendar_to_timestamp($_POST['start_date'.$section_id]);
$namesection = ($_POST['namesection'.$section_id]);
}
if(trim($_POST['end_date'.$section_id]) == '0' OR trim($_POST['end_date'.$section_id]) == '') {
$publ_end = 0;
$namesection = ($_POST['namesection'.$section_id]);
} else {
$publ_end = jscalendar_to_timestamp($_POST['end_date'.$section_id], $publ_start);
$namesection = ($_POST['namesection'.$section_id]);
}




if($sql != '')
$sql .= ",";
$sql .= " publ_start = '".$admin->add_slashes($publ_start)."'";
$sql .= ", publ_end = '".$admin->add_slashes($publ_end)."'";
$sql .= ", namesection = '".$admin->add_slashes($namesection)."'";
}

this makes it possible to give each section a name

to display this in the edit-page:

open the modify.php in admin/pages and at the bottom there is probably something that looks like this

Code:
// Get sections for this page
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
$query_sections = $database->query("SELECT * FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
if($query_sections->numRows() > 0) {
while($section = $query_sections->fetchRow()) {
$section_id = $section['section_id'];
$module = $section['module'];
$namesection = $section['namesection'];




//Have permission?
if(!is_numeric(array_search($module, $module_permissions))) {
// Include the modules editing script if it exists
if(file_exists(WB_PATH.'/modules/'.$module.'/modify.php')) {
echo '<div style="border-top: 1px solid #239DCB;margin-top:5px; padding-top:10px;"><a name="'.$section_id.'"></a>

<div style="color:#666;margin-bottom:5px;float:left; text-align:left;"><h2>'.$namesection.'</h2></div>

<div style="color:#666;margin-bottom:5px;float:right; text-align:right;">module type: <span style="color:#239DCB; font-weight:bold;">'.$module.'</span> | Pagina-section:<span style="color:#239DCB; font-weight:bold;"> '.$section_id.' </span><br /><br />
</div>
</div><br />


<br />
';

note: sometime ago I added some other extra's there so I it will look slightly different

ps PLEASE ENCLOSE THIS OR SOMETHING LIKE THIS IN WB3
Logged
Bug

Offline Offline

Posts: 188


« Reply #1 on: November 08, 2011, 10:32:05 PM »

Tomorrow i wil do an update where also the name of the block from the info file is displayed

Great hah!
Logged
Bug

Offline Offline

Posts: 188


« Reply #2 on: November 09, 2011, 08:45:35 AM »

added the row 'nameblock' to the database (phpmyadmin, section table, add 1 -  call it 'nameblock'


- - - - -


in admin/pages/sections.php

added
Code:
            <input type="hidden" class="inputveldje" id="nameblock<?php echo $section['section_id']; ?>" name="nameblock<?php echo $section['section_id']; ?>" value="<?php foreach($block AS $number => $name) { if($number == $section['block']) { echo $name; } } ?>" style="width: 100px;" />
   

to the tablerow that displayes the info for each created section


- - - - -

in admin/pages/sections_save.php

added some lines to save the new values from the form to the database:

Code:
// update publ_start and publ_end, trying to make use of the strtotime()-features like "next week", "+1 month", ...
if(isset($_POST['start_date'.$section_id]) AND isset($_POST['end_date'.$section_id])) {
if(trim($_POST['start_date'.$section_id]) == '0' OR trim($_POST['start_date'.$section_id]) == '') {
$publ_start = 0;
$namesection = ($_POST['namesection'.$section_id]);
$nameblock = ($_POST['nameblock'.$section_id]);
} else {
$publ_start = jscalendar_to_timestamp($_POST['start_date'.$section_id]);
$namesection = ($_POST['namesection'.$section_id]);
$nameblock = ($_POST['nameblock'.$section_id]);
}
if(trim($_POST['end_date'.$section_id]) == '0' OR trim($_POST['end_date'.$section_id]) == '') {
$publ_end = 0;
$namesection = ($_POST['namesection'.$section_id]);
$nameblock = ($_POST['nameblock'.$section_id]);
} else {
$publ_end = jscalendar_to_timestamp($_POST['end_date'.$section_id], $publ_start);
$namesection = ($_POST['namesection'.$section_id]);
$nameblock = ($_POST['nameblock'.$section_id]);
}




if($sql != '')
$sql .= ",";
$sql .= " publ_start = '".$admin->add_slashes($publ_start)."'";
$sql .= ", publ_end = '".$admin->add_slashes($publ_end)."'";
$sql .= ", namesection = '".$admin->add_slashes($namesection)."'";
$sql .= ", nameblock = '".$admin->add_slashes($nameblock)."'";
}

alle stuff regarding namesection and nameblock are the new / extra lines

- - - -

at the bottom of the admin/pages/modify.php there is some code to display the sectionnumber...

I added some stuff there

Code:
// Get sections for this page
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
$query_sections = $database->query("SELECT * FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
if($query_sections->numRows() > 0) {
while($section = $query_sections->fetchRow()) {
$section_id = $section['section_id'];
$module = $section['module'];
$namesection = $section['namesection'];
$nameblock = $section['nameblock'];
$block = $section['block'];




if (empty($nameblock)){
$nameblock = ' ';
}else{
$nameblock = 'Positie op de website : <span style="color:#239DCB; font-weight:bold;">'.$nameblock.'</span> | ';
}







//Have permission?
if(!is_numeric(array_search($module, $module_permissions))) {
// Include the modules editing script if it exists
if(file_exists(WB_PATH.'/modules/'.$module.'/modify.php')) {
echo '<div style="border-top: 1px solid #239DCB;margin-top:5px; padding-top:10px;"><a name="'.$section_id.'"></a>

<div style="color:#666;margin-bottom:5px;float:left; text-align:left;"><h2>'.$namesection.'</h2></div>

<div style="color:#666;margin-bottom:5px;float:right; text-align:right;">'.$nameblock.'modulesoort: <span style="color:#239DCB; font-weight:bold;">'.$module.$dop.'</span> | Pagina-onderdeelnummer:<span style="color:#239DCB; font-weight:bold;"> '.$section_id.' </span><br /><br />
</div>
</div><br />


<br />
';
require(WB_PATH.'/modules/'.$module.'/modify.php');
}
}
}
}

// Print admin footer
$admin->print_footer();

?>

sorry for the dutch language in the code, just change those words to your tongue..

- - - - -

why would you wanna do this:

to make the backend more clear!


Logged
dbs
WebsiteBaker Org e.V.

Offline Offline

Posts: 3719


WWW
« Reply #3 on: November 09, 2011, 08:51:00 AM »

another nice idea!
will test it.
Logged

Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!