Possible to reorder page attributes in the properties menu of a page?

Permalink 3 users found helpful
I notice that the custom page attributes of a page display in the order that they were added, on page types they are associated with. Is there any way to reorder these attributes for usability and logical display?

brennaH
 
frz replied on at Permalink Reply
frz
stick it in feature requests, i don't think it easily is today
olacom replied on at Permalink Reply
olacom
Is there a way to do it manually in the db ?
jhart replied on at Permalink Reply
i really need this as well...

i need to show a certain attribute above another in the properties > custom attributes tab.
olacom replied on at Permalink Reply
olacom
Bump-

This seriously causing me some problems with my clients. Is there a way to do it manually in the db ? I cant figure out where.

Thanks
BigBobbyD replied on at Permalink Reply
BigBobbyD
This feature would be very helpful...

Olacom - You may have a stronger skill-set than I do, but, for what it's worth, I royally screwed screwed thing up trying to re-order attributes in the db. Wound up paying someone to rebuild a client's site in a new db.

You may be better off creating new attributes in the order you want, fixing up whatever code needs fixing in order to reference them, then deleting the old attributes...
Quaro replied on at Permalink Reply
There was a patch posted in the old 'feature requests' forum that added this feature:

http://www.concrete5.org/private/features/ability-to-reorder-page-a...

That area isn't in use any longer -- anyone tried the patch in 5.4? I agree this is a minor thing but extremely aggravating when you need it. Having one attribute way out of place looks sloppy.
jhart replied on at Permalink Reply
bump. must have this...
olacom replied on at Permalink Reply
olacom
bump again!
glockops replied on at Permalink Reply
glockops
I would like this feature.

I'd also like the default behavior of the assignCollectionAttribute() changed when installing a custom package. The first attribute to be assigned to a custom page type, should be the first attribute that is added to the custom attributes tab.

It's absolutely crazy how attributes are assigned at the moment. I've been working on trying to get the attributes to display in a particular order for over 3 hours. The ordering of assigned attributes appears to be completely random.
johndorsay replied on at Permalink Reply
johndorsay
This may be a bad spot to place this but, since so many were asking for it, this is the fix to make your page attributes draggable in order.

REMEMBER that this will be altering the core files so when you upgrade this will be overridden

@c5 core team, if this is too over the top, let me know and i can move it into a 'how to section' maybe.... or...

Sortable Page Attributes

1. Create a new table 'AttributeKeysOrder' with fields akID (int), akOrder(int).

2. edit concrete/single_pages/dashboard/pages/attributes.php
Alter line 47 to this
<?php  $attribs = CollectionAttributeKey::getListByOrder(); ?>


3. Edit concrete/models/attribute/key at line 102 by adding this function
public static function getListByOrder($akCategoryHandle = 'collection', $filters = array()) {
     $db = Loader::db();
     $q = 'select akID from AttributeKeys inner join AttributeKeyCategories on AttributeKeys.akCategoryID = AttributeKeyCategories.akCategoryID where akCategoryHandle = ?';
      foreach($filters as $key => $value) {
         $q .= ' and ' . $key . ' = ' . $value . ' ';
      }
      $r = $db->Execute($q, array($akCategoryHandle));
      $list = array();
      $listOrder = array();
      $txt = Loader::helper('text');
      $className = $txt->camelcase($akCategoryHandle);
      while ($row = $r->FetchRow()) {
         $c1 = $className . 'AttributeKey';
         $c1a = call_user_func_array(array($c1, 'getByID'), array($row['akID']));
         if (is_object($c1a)) {


4. Edit concrete/elements/collection_metadata_fields.php line 83 to this
<?php  $cAttributes = CollectionAttributeKey::getListByOrder();


5. Edit concrete/elements/dashboard/attributes_table.php
at line 86 replace with this line
<div class="ccm-attributes-list ak_sortable">


at line 129 add
$("div.ak_sortable").sortable({
      handle: 'img.ccm-attribute-icon',
      cursor: 'move',
      opacity: 0.5,
      stop: function() {
         var ualist = '&akOrder=' + $(this).sortable('toArray');
         //alert (ualist);
         //ualist += '&akID=<?php echo $c->getCollectionID()?>';
         //ualist += '&asID=' + $(this).attr('attribute-set-id');
         $.post('<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>/dashboard/attribute_order_update', ualist, function(r) {
            alert(r);
         });
      } 
   });


6. Create a file in concrete/tools/dashboard/attribute_order_update.php
<?php 
defined('C5_EXECUTE') or die(_("Access Denied."));
$canRead = true;
$ch = Page::getByID($_REQUEST['cID']);
$path = $ch->getCollectionPath();
if (strpos($path, '/dashboard') === 0) {
   $cp = new Permissions($ch);
   if ($cp->canRead()) {
      $canRead = true;
   }
}
if (!$canRead) {
   die(_("Access Denied."));
}
// this should be cleaned up.... yeah


that should be it. And be careful...
andrew replied on at Permalink Reply
andrew
Thanks John. This is a great solution. We are in the process of re-thinking how the page attributes overlay works (in terms of speed, attribute ordering, and attribute grouping) so I don't know that we're going to incorporate this (since it would be temporary) - but this is a great concise and easy to understand solution for those who want or need it now.
glockops replied on at Permalink Reply
glockops
Just pointing out the step #4 got stuck in with step #3.

Otherwise this thing works great.
johndorsay replied on at Permalink Reply
johndorsay
thanks for the heads up, i've fixed the post, so it now looks better :)
TheRealSean replied on at Permalink Reply
TheRealSean
Has any of this been added to the core?

I just realised after adding an image and text editor as attributes that I need to have the Editor first, (problems with replacing the image otherwise).

I don't mind mucking about in the core, but would like to know if we are any closer (core wise) to having this done. Without having to do this for every update of c5.
fanto replied on at Permalink Reply
bumpety bump

Looking for a way to do this as it's not in the most uptodate C5.6.2 and the solution above references parts of files that don't exist anymore.

Anyone got a solution for this at all?
crferguson replied on at Permalink Reply
Come on guys, this can't be that complicated to implement. There is no point in being able to drag around the attributes and they then display in some other order. Please can we have this fixed. its been a long, long wait.
jordanlev replied on at Permalink Best Answer Reply
jordanlev
If you're running Concrete version 5.6 or higher, I've got a solution for you:
http://concrete5tricks.com/blog/sorting-custom-attributes-in-page-p...

I also submitted pull requests so hopefully this makes it into a future release:
5.6:https://github.com/concrete5/concrete5/pull/1572...
5.7:https://github.com/concrete5/concrete5/pull/1573...

-Jordan
fanto replied on at Permalink Reply
Finally got around to implementing this, works like a charm.

Thanks!