Modx - Add custom field to mod_site_content - modx

Is it possible to add a custom field to modx_site_content? What I'm trying to accomplish, is to add a field t_id. I've already added this in the database. However, when I save it using: $object->save(); nothing is saved for that field, it just comes up as Null.
The version I'm using is: MODX Revolution 2.2.4-pl (June 14, 2012)

Actually - I've answered that question before. You want to create a separate table and schema.
modx evolution external database
however - it looks like you want to add a field so that you can call it as part of the page/template in modx? You may have to write a plugin to extract that data at the same time as the resource.

I know this is an old topic, but now the ClassExtender extra will create the additional table for you based on your schema, add the additional fields to the Create/Edit Resource panel with a plugin, and save those field values to the table in the DB when the Resource is saved in the Manager. This can save a lot of time and trouble.
If you can wait, a new version that works in MODX 3 should be released soon.

Related

Is there a simple example on how to add an entity extension for customers with field in the admin of shopware 6?

I want to add an entity extension to a customer in shopware 6. I was able to do so with the examples in the documentation of shopware on the PHP side and now I wonder how to display and modify this new "field" in the shopware 6 backend.
I searched a lot and also tried to find a simple plugin where I could get some inspiration from, but unfortunately I'm not able to find.
So again the question 😊 Is there any simple example on how to add an entity extension for customers with field in the admin of shopware 6? Or an example plugin, where I can see how it could be done?
What you're (likely) trying to achieve would be the combination of multiple separate tasks.
If you want to store data in the database you'd need a new custom entity
If you want to associate the new entity with the customer you'll need the entity extension
You'll need to add a new field in the administration
I've linked to examples respectively, but you'll probably need to take the time and invest in studying the documentation regardless.
I also created an example plugin that combines all these steps and adds a new entity with a height field as association to the customer and displays the field in the administration. You can find the repository here.
Not sure if you considered this, but depending on what you are trying to accomplish, the simplest way is probably adding a custom field (this can be done progamatically or even via the admin panel).
The drawback is, that those fields' values are stored as JSON and it has drawbacks when you try to search through them.

Update Kentico document field regardless of versioning

I have a field on one of my base page types which I need to update programmatically from an external data feed, so that it can be included in my Smart Search index.
The documents are versioned, but I want to update the published value of this field regardless of checkout state, and obviously avoid any sort of overwrite when documents are checked in.
The field will not appear on the editor form -- or ideally, would conditionally display for Global Admins.
It appears that using the API to update the document without doing a CheckOut fails silently. However if I do a Checkout/Update/CheckIn on a checkout-out page, the author will lose their work I assume?
Any way to handle this "versionless" field via the Kentico data model and API?
I don't think there is a way around updating checked out pages. You can update the page type table directly, but as you mentioned, it will be overwritten when they check in. You could update the version history I believe to make changes to the current data that is checked out, but again, I think that will be lost if the user cancels.
The only way I can think of to solve your issue is to create another table that maps the values you want to the page. Then you don't have to worry about the pages being checked out, you just need to grab the documentID or something. Since the value isn't displayed to the editor, you just have a field that does a lookup on this table.
The preferred and right way is using the API but as you stated, it causes problems if a user has something already checked out and working on it or it's in workflow and not published yet.
If the field you're updating is page type specific, there is one thing specifically I can think of and that's going directly to the database to the page type's database field and perform an update to that field.
Note: this is not recommended unless you know specifically what you're doing and have done full testing on it
The down side of going direct to the database is this will not update the current version since you're using check in/out and workflow. You will also need to update the checked out and current version which means you need to:
Go to the Document itself in the cms_documents table and get the document you are working with.
Then using the fields DocumentCheckedOutVersionHistoryID and DocumentPublishedVersionHistoryID' you can get the version history IDs of the document from theCMS_VersionHistory` table.
Then you can perform an update to the CMS_VersionHistory and your custom page type fields.
You will then need to look in the CMS_WorkflowHistory table and find out if that document is in workflow and in what step.
After you have that workflow history step, use the VersionHistoryID field to go back to the CMS_VersionHistory table and update that record with your data.
Again, not an elegant solution since you are using check in/out and workflow but after some trial and error and testing you should be able to figure it out.
UPDATE
You may also be able to add a custom table or some other linked database table which will allow you to create a global handler. The linked table would be where you perform your updates via API and other calls without versioning or workflow. Then when a user updates a specific page type you could do a check to see when the last time that linked table was updated and update the field(s) you need on update of that particular page (of course by node and document IDs).
Unfortunately you'll have to check it in and out with API. See examples here.
Also you might need to publish it in order to reflect changes on the live site.

modx revo adding fields in user module

I am new to modx revo and trying to add extra fields in user creation from backend. Which file should i check out for customization. I added the custom field in backend with this code on modx.panel.user.js file.
{
id: 'modx-user-companyname'
,name: 'company_name'
,fieldLabel: _('company_name')
,xtype: 'textfield'
,anchor: '100%'
,maxLength: 255
}
I created custom column named company_name in database table modx_users but I don't know how to save it on database. Any ideas?
Editing the core code of modx is considered a bad idea.
Really you have two options if you want to add extra properties to users...
Firstly you could take advantage of modUser extended field which allows you to store extra properties for the user and are stored as JSON. This is available in the default ui in the manager.
See Understanding MODX Extended User Fields and JSON
Secondly, you could extend modUser. This would give you full control over the user model and could then add additional related entities. From then, you might be able to alter the user form in the manager with form customisation or write a plugin to alter view.
See Extending modUser

Creating/Amending Field with Dependencies? - Microsoft Dynamics CRM 2011

What is the easiest way to change a field with a whole plethora of dependencies?
In the ‘Company’ section when you add a new call, there a field called ‘Summary’ I want to either amend or replace this with a field that has a drop down menu, but when I looked in to it, that field has some 28 dependencies so if I create a new field, how do I ensure I have got this bit right?
Many thanks
Nick
Not sure there is a quick way to do this - especially when you consider that changes would have to be replicated in any other environment you have deployed to, I would suggest:
Make a new field.
Mark the old field as redundant, e.g. add (REDUNDANT) in front of the name.
Work your way through moving dependencies from the old field to the new. When the old field has no dependencies you know your work is complete.
When you import to any other environment the old field will still exist but will be totally unused.
If the original field was populated perform a data migration to populate the new field.

Drupal: How to add a form and perform functionality on it

I am new to Drupal and trying to get hand on it.
I am not able to find how to have the following functionality on my site. If anyone can help me out, it would be great for me.
I need to have a form that will take 2 fields one of which is supposed to be the login id(how to retrive login id?). I need to store this and display in tabular form also on a new page. Lastly I want to provide an edit form for this functionality using the same form but its use will be like whenever a person adds value in this form, it checks in Table1, if entry is not present it adds in table, else it updates the table.
Apart from this I need to store all the updations in a seperate table or something like that, so that I am able to see the history of all the changes
Eg:
ADD Form:
Fields:
- LoginID
- Phone number
Show Table Page(Tabular with the stored information)
Edit Form(same as above form):
Fields:
- LoginID
- Phone number
Now If I add my phone number to this it will get stored. Later when I try to modify my number it should update in initial table but also store the history of old and new entry in a separate table so that I can perform varies options on it.
I also dont know how to add/enable form fields in drupal. :(
Thanks
I'm not entirely sure what you're asking, but I think the Computed Field module might be helpful. The module allows you to define custom hooks that run when a node is saved.
If you're not creating nodes and are using something like the Webform module, you should be able to write a module to process the data.

Resources