Page 1 of 1
Admin new content drop down
Posted: Wed Feb 18, 2009 5:58 pm
by gap_tooth_clan
Hi I have been developing a client site to display work, the site architecture is as this
>home
>client 1
>project 1
>view 1
>view 2
>project 2
>client 2
Now say view 1 had been superceded by a new design I would want to add content view 1a which would supercede view 1.
So what I need is a drop down list in the admin area like the parent drop down so I can show which page has been superceded and which one has replaced it. So possibly two drop downs but I am sure I can work this out. I really could do with a point in the right direction
Re: Admin new content drop down
Posted: Wed Feb 18, 2009 9:19 pm
by grailwebd
I don't understand what you are asking
Re: Admin new content drop down
Posted: Thu Feb 19, 2009 9:14 am
by gap_tooth_clan
I am looking to add a new drop down menu in the admin area when editing content that has a list of pages like the parent drop down.
Re: Admin new content drop down
Posted: Thu Feb 19, 2009 12:17 pm
by gap_tooth_clan
Ok kind of got a start on this I will update this post as I go through
If you follow this through you will be able to add a new drop down menu in the admin area, I took this further and made changed CreateSupercededByDropdown to accept the parent_id value in the parameters that I passed to another new function called function &GetAllSiblingContent($parentId, $loadprops=true) which was a copy of getAllContent except in the sql statement there is a where statement to only get siblings for the content. I did originally think that I needed to add this var $mOldSupercededById; as the parent drop down has this but it was not nessarcary.
lib>classes>class.content.php
// added to varibales at the top
var $mSupercededById;
var $mOldSupercededById;
// added to function SetInitialValues()
$this->mSupercededById = 0 ;
$this->mOldSupercededById = 0 ;
//
function SupercededById()
{
return $this->mSupercededById;
}
function SetSupercededById($SupercededById)
{
$this->DoReadyForEdit();
$this->mSupercededById = $SupercededById;
}
function OldSupercededById()
{
return $this->mOldSupercededById;
}
function SetOldSupercededById($OldSupercededById)
{
$this->DoReadyForEdit();
$this->mOldSupercededById = $OldSupercededById;
}
// added this to function LoadFromId($id, $loadProperties = false)
// need to get info from the database
// need to add superceded_by_id to cms_content in the database
$this->mSupercededById = $row->fields["superceded_by_id"];
$this->mOldSupercededById = $row->fields["superceded_by_id"];
// added this to function function LoadFromData($data, $loadProperties = false)
// I assume that this is the method to get post data
$this->mSupercededById = $data["superceded_by_id"];
$this->mOldSupercededById = $data["superceded_by_id"];
// added to function Update()
// Changed the $query
// added 'superceded_by_id = ?,' after parent_id = ?
// added '$this->mSupercededById,' after mParentId
/*-------------------------------------------------
Got to this point and dont think I need to have mOldSupercededById
-------------------------------------------------*/
// Added to function Insert()
// updated the $query with 'superceded_id,' after parent_id
// added '$this->mSupercededById,' after $this->mParentId,
lib>classes>contenttypes>Content.inc.php
// under this line $ret[]= array(lang('parent').':',$contentops->CreateHierarchyDropdown($this->mId, $this->mParentId));
// add
$ret[]= array(lang('supercededby').':',$contentops->CreateSupercededByDropdown($this->mId, $this->mSupercededById));
add this
if (isset($params['superceded_by_id']))
{
$this->mSupercededById = $params['superceded_by_id'];
}
lib>classes>class.contentoperations.inc.php
//find the function CreateHierarchyDropdown($current = '', $parent = '', $name = 'parent_id', $allowcurrent = 0)
// now copy and rename CreateSupercededByDropdown
admin>lang>en_USadmin.inc.php
add $lang['admin']['parent'] = 'Parent';
after $lang['admin']['supercededby'] = 'Superceded By';
ok after adding all this to the core I really wanted to be able to use this information in the template so
needed to add to the $gCms
lib>classes>class.pageinfo.inc.php
add
var $superceded_by;
$this->superceded_by_id = -1;
add this to both sql statements
c.superceded_by_id,
and this line too
$onepageinfo->superceded_by_id = $row['superceded_by_id'];
I then created a UDT tag to get the variable from $gCms not sure if this was the best way to do this but it worked so I am not complaining
global $gCms;
global $smarty;
$manager =& $gCms->GetHierarchyManager();
$supercededBy = $gCms->variables['pageinfo']->superceded_by_id;
$smarty->assign('superceded_by' ,$supercededBy);
Re: Admin new content drop down
Posted: Fri Feb 20, 2009 2:44 pm
by calguy1000
You realize with hacking the core like this... your site is no longer eligible for support. right?
Re: Admin new content drop down
Posted: Fri Feb 20, 2009 4:37 pm
by gap_tooth_clan
Was not really aware of that but it makes sense you guys shouldnt be responsible for my crappy coding. I had a look at the documentation for changing the core but could not see anything, could you point me in the right direction?
I created the majority of my site with the available modules and a few minor tweaks, which I feel for an open source piece of software is amazing. Considering my site is pretty far from the concept of a CMS! I just could not really see any other way to achieve this functionality but to hack the core.
I thought this post may be helpful to anyone else who was having difficulties trying to add new functionality, I am not the best PHP programmer and finding my way through the maze of files.
Re: Admin new content drop down
Posted: Fri Feb 20, 2009 4:45 pm
by calguy1000
it's fine, go through and hack as much as you want... that's the power of open source code.
However... don't hack the code (wether you do it yourself, find a post on the forum, or get somebody else to do it). (this applies even if you're fixing a bug, or a perceived bug). then come in and ask us to answer questions about problems you're having on the same site. It just makes us extremely angry when we spend hours trying to reproduce/hunt-down a reported bug, just to find out it's a problem caused by the hacking that was done.
Then trying to send that guy an invoice for our time is next to impossible.
Re: Admin new content drop down
Posted: Tue Feb 24, 2009 12:04 pm
by gap_tooth_clan
I think everyone should take note of that, I get enough of that at work and it is just so stupid.
Programming tip of the day: Dont be stupid.
That is my mini tutorial finished anyone has any questions feel free to email me.