Jump to content


Photo

What's best practice for modifying global meta data?


  • Please log in to reply
5 replies to this topic

#1 JoshCook

JoshCook

    Newbie

  • New Members
  • Pip
  • 2 posts

Posted 21 June 2012 - 03:24 PM

I was curious what the proper way to change this data once it's been serialized and stored in the database?

I've been using zermo for a couple days now, playing around with it, and I've changed the name "Accounts" to something else. This created an entry in the globalmetadata table for accounts to store this name change. Now I want to make another change (I am currently trying to add a tab to the tabMenuItems). Since there is an entry in the globalmetadata table, it appears that it now ignores the data found in the getDefaultMetaData() function.

modules/accounts/AccountsModule.php
array(
   'label' => 'Create AccountsModuleSingularLabel',
   'url'   => array('/accounts/default/create'),
   'right' => self::RIGHT_CREATE_ACCOUNTS
 ),
 array(
    'label' => 'AccountsModulePluralLabel',
    'url'   => array('/accounts/default'),
    'right' => self::RIGHT_ACCESS_ACCOUNTS
 ),
 array(
    'label' => 'AccountsModulePluralLabel Test',
    'url'   => array('/accounts/default'),
    'right' => self::RIGHT_ACCESS_ACCOUNTS
 ),

I can get my tab to appear a couple of ways. 1) I can manually manipulate the serialized data in the globalmetadata table to include the new tabMenuItem, but that is difficult and prone to problems. 2) I can delete the entry in the globalmetadata table entirely and have it be re-written from the getDefaultMetadata function, but then I loose my name change.

I am hoping for a solution is something like "updateMetadata()" that will deserialize the metadata, make only the change I am asking for, and re-serialize and save it. Now this function wouldn't be very hard to write, but I want to make sure I'm not duplicating work that has already been done and I am curious where to call said function (maybe in one of the account controller functions?)
I was hoping that appending &clearCache=1 to the query might help resolve my problem, or the debug options to not use memcache, phpcaching, etc, but none of these seem to do quite what I want.

Thanks so much in advance,
Josh

#2 Jason

Jason

    Administrator

  • Administrators
  • 864 posts
  • LocationChicago

Posted 21 June 2012 - 04:20 PM

I was curious what the proper way to change this data once it's been serialized and stored in the database?

I've been using zermo for a couple days now, playing around with it, and I've changed the name "Accounts" to something else. This created an entry in the globalmetadata table for accounts to store this name change. Now I want to make another change (I am currently trying to add a tab to the tabMenuItems). Since there is an entry in the globalmetadata table, it appears that it now ignores the data found in the getDefaultMetaData() function.

modules/accounts/AccountsModule.php

array(
   'label' => 'Create AccountsModuleSingularLabel',
   'url'   => array('/accounts/default/create'),
   'right' => self::RIGHT_CREATE_ACCOUNTS
),
array(
	'label' => 'AccountsModulePluralLabel',
	'url'   => array('/accounts/default'),
	'right' => self::RIGHT_ACCESS_ACCOUNTS
),
array(
	'label' => 'AccountsModulePluralLabel Test',
	'url'   => array('/accounts/default'),
	'right' => self::RIGHT_ACCESS_ACCOUNTS
),

I can get my tab to appear a couple of ways. 1) I can manually manipulate the serialized data in the globalmetadata table to include the new tabMenuItem, but that is difficult and prone to problems. 2) I can delete the entry in the globalmetadata table entirely and have it be re-written from the getDefaultMetadata function, but then I loose my name change.

I am hoping for a solution is something like "updateMetadata()" that will deserialize the metadata, make only the change I am asking for, and re-serialize and save it. Now this function wouldn't be very hard to write, but I want to make sure I'm not duplicating work that has already been done and I am curious where to call said function (maybe in one of the account controller functions?)
I was hoping that appending &clearCache=1 to the query might help resolve my problem, or the debug options to not use memcache, phpcaching, etc, but none of these seem to do quite what I want.

Thanks so much in advance,
Josh

Depends on what you are using this for. The best thing to do is how it is done in the ZurmoZoo example. Where you have a

http://hg.zurmo.org/...mManagement.php

and here:

http://hg.zurmo.org/...InstallUtil.php

Then you can easily run this from the URL by adding ?resolveCustomData=1

The nice thing about this approach, is that then if you want to run the install again, this will get processed during the installation. Hope this helps, if you need more help please post more questions.

Another nice thing about this approach is it keeps it upgrade safe because you aren't changing any core files.

Jason Green
Zurmo Team
Need support? Upgrade now


#3 JoshCook

JoshCook

    Newbie

  • New Members
  • Pip
  • 2 posts

Posted 21 June 2012 - 09:17 PM

That was perfect. Exactly what I was looking for. I have been looking at that tutorial quite a bit lately and was not quite sure what those two files were doing. Not only did you answer my question, but now I understand the purpose of those files much better. And
"?resolveCustomData=1" is a gem.
Thanks again, I think your answer helped me more than either of us probably thought it would.

#4 Jason

Jason

    Administrator

  • Administrators
  • 864 posts
  • LocationChicago

Posted 21 June 2012 - 09:39 PM

That was perfect. Exactly what I was looking for. I have been looking at that tutorial quite a bit lately and was not quite sure what those two files were doing. Not only did you answer my question, but now I understand the purpose of those files much better. And
"?resolveCustomData=1" is a gem.
Thanks again, I think your answer helped me more than either of us probably thought it would.

I wish we could document this somehow better. Can you help us re-word the wiki? Or maybe make some additional tutorial or something? I am just trying to think how to make it easier for the next person.

Jason Green
Zurmo Team
Need support? Upgrade now


#5 ruudbwai

ruudbwai

    Member

  • New Members
  • PipPip
  • 11 posts

Posted 17 May 2013 - 11:26 AM

Hi guys, ok that's fine for custom modules, but is it possible to modify existing metadata after installing the app? Say you want to change the tabs menu items, and I want say leads at the bottom, or contacts before accounts etc, is there a way to accomplish this? without changing the order in modules/zurmo/ZurmoModule.php before install?

 

thanks.



#6 raysto

raysto

    Zurmo Team

  • Administrators
  • 1,973 posts

Posted 31 May 2013 - 02:37 PM

In an upcoming version, you will be able to organize the menu tabs and put one above or below another. Join the next Dev Session and we can chat about how to change metadata.


Ray Stoeckicht
Zurmo Team
Try Zurmo Pro





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users