how to create objects with same name(key) in same fodler?

Instructions, Demos, Insight and How-Tos.
Post Reply
nipunkumar
Posts: 9
Joined: Thu Nov 13, 2014 8:23 am

how to create objects with same name(key) in same fodler?

Post by nipunkumar » Fri Dec 12, 2014 2:13 pm

How can I create 2 objects with same name (object key) in same folder?

User avatar
IgorBenko
Posts: 689
Joined: Thu Jul 21, 2011 4:33 pm
Location: Berlin
Contact:

Re: how to create objects with same name(key) in same fodler

Post by IgorBenko » Fri Dec 12, 2014 2:18 pm

That's not possible and undesired for many reasons. Why would you like to do that?

Cheers, Igor
basilicom GmbH - Official Pimcore Selected Company - http://basilicom.de/de/pimcore

kathleenrueb
Posts: 3
Joined: Thu May 28, 2015 1:22 pm

Re: how to create objects with same name(key) in same fodler

Post by kathleenrueb » Mon Sep 28, 2015 10:53 am

Based on my experience with open-source multichannel platform like pimcore, I think it is not possible. As Igor has asked, what is the purpose of doing so? Just eager to know!

User avatar
johan.lindgren@ateles.se
Community Support
Posts: 871
Joined: Fri Apr 27, 2012 8:18 am
Location: Sweden
Contact:

Re: how to create objects with same name(key) in same fodler

Post by johan.lindgren@ateles.se » Mon Sep 28, 2015 12:21 pm

Hi.

It's correct that you can not have to objects with the same key in the same folder.

You could though manipulate the label visible in the tree in admin. The code below changes that label to the value of the attribute "name".

Code: Select all

\Pimcore::getEventManager()->attach("admin.object.treeGetChildsById.preSendData", function ($e) {
    $returnValueContainer = $e->getParam('returnValueContainer');
    $data = $returnValueContainer->getData();   
    for($i=0; $i<count(array_keys($data)); $i++){
       $object = \Object::getById($data[$i]['id']);
       $value = "(" . $object->getKey() . ") " . $object->getName();
       $data[$i]['text'] = $value;
    }   
    $returnValueContainer->setData($data);   
});


https://www.pimcore.org/wiki/pages/view ... d=14551652

As you can see in the code you could also leave out the key in the label, but for sorting it might look better with the key there?

I'm curios, why would you like to have two objects with the same key in the same folder? I guess it could make sense if they have different classes and hence different icons?

/Johan
---------------------------------------------------------------------
Ateles Consulting AB - a Pimcore Professional Partner

Post Reply

Return to “Tips & Tricks”



Who is online

Users browsing this forum: No registered users and 1 guest