Drupal dynamic Taxonomy term values - drupal-7

I'm new to Drupal, and somehow miss a feature. (or I guess just don't know how to activate it)
Let's say I have a content type which is using the term reference (taxonomy field type)
Is it possible to have it filled dynamically (e.g. with already existing content from my site?
I don't want to type in all possible Tag/Term options, but instead want some kind of dynamic category choice for an author, e.g. feeded by existing content (articles/pages) from the drupal site itself.
Is there a certain module I need or how is it done?

If you want to add to your nodes a reference to another node in your site you need to use a node reference field and not a term reference. To be able to add that kind of field to your content type, you need to install References module, and probably Views to show pages that leverage your references. If you provide some details of your requirements I can be more specific.

Related

Accessing CustomFieldDefinition metadata via tooling api

So, I've been attempting to gather picklist dependencies per Opportunity record type for my lightning components. I have been able to retrieve Standard Field dependencies by RecordType, but it the Tooling API will not return the custom field dependencies. Standard calls and queries will not work either, as they state that the field has no controlling value or dependency.
Given this information I suspected that there was a table that is hidden somewhere that contains the keys for the RecordType and FieldDefinition, hopefully with a nested Metadata object.
I found an Id in one of the parameters in the setup menu for a Record Type and Id.getSObjectType() on it. The table name is CustomFieldDefinition. However, it is not accessible via SOQL or the Tooling API.
Has anyone accessed this table? Or has anyone been able to retrieve the field-record type picklist dependencies on custom fields AND standard fields?Tooling API ResponseDebug Log with SObject Name
I think you're doing it wrong.
"Controlling field" would be another picklist or a checkbox for example, something you change during same edit action. If you have dependency to record type - in that sense it's not a controlling field. Sure, you change record type and picklist changes - but really everything would change, it should be a different page layout (different fields shown, marked readonly/required etc). There's a reason that record type change is not done on normal edit screen, you do it by clicking special link on detail view and then everything "explodes".
Have a look at "User Interface API" - set of tools meant to help your custom app (mobile? desktop?) steal recreate a normal page layout. This one might be especially useful: https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_picklist_values_collection.htm
There's even a Trailhead: https://trailhead.salesforce.com/en/content/learn/modules/user-interface-api (skim through whole set but especially read last module)
And since you mentioned Lightning Components - are you aware of these ready tools:
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_ui_api
getPicklistValuesByRecordType
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_generate_record_input_create
or maybe you don't have to code it all and stuff like <lightning-record-edit-form> with recordtypeid passed to it will solve all your problems
Have a look, if I didn't give you a working solution then at least you have some keywords to Google around. If you're still stuck - try to post a code sample as new question?

drupal 7 metatags by content type

I have different custom content types which need completely different tailored for them meta description tags. I have installed the metatags module, however, it gives the possibility to add description meta tags on a site-wide basis and not by content types. The same is with page titles (tho, this can still be solved with the page title module). So i wanted to ask if anyone might know of a good solution to this?
I was also thinking if there is a way to use conditional operator for token, for example, to see if a field is set for a particular node, then add the content of the field to the meta description/keywords.
You can add content type specific meta tags at /admin/config/search/metatags/config/add. There's a drop-down list that lets you create default metatags by a number of entity attributes, including content type.
I've never integrated tokens with metatag but it appear to be adequately supported.

Create new field type for custom content

I want to create a new content type called "Message". It will have a couple of fields, "message-body" which will be plain text and "addressees". The addressees field should reflect a list of the registered users of the site.
The idea is to create a field type that will be a checklist where all users of the site can be selected, and those that are will receive the message in "message-body" via drupal_set_message($msg).
I am not suceeding so far in creating a custom field type. The Field API documentation is not very clear.
Thanks.
You maybe already found the solutions for you problem.
I think in your case you can use Entity Reference. In your custom content type you can create a new field with the Entity Reference type. Then on the configuration page you can choose which entity to reference, like node, taxonomy or users, with different types of widget.
Here's a link of the Entity Reference module.
Why not make a content type via the menu interface www.yoursite.com/admin/structure/types/add.
Or you need it as a module that you can re-distribute?
An easier way then is to make use of features. It allows you to 'export' a built content type into a module. Enabling the module (on another site), then creates all the fields that where in the export.

When creating a Drupal 7 content type programmatically, is there a way to add tuples of fields?

In Drupal 7, I'd like to create a Person content type. A person may have multiple profiles - an administrator should be able to select which profile will be considered the primary one. So, that means that I need a tuple consisting of:
A textarea, for the profile text
A checkbox, indicating that this is the primary profile
A textbox, for naming this particular profile
I need functionality to behave like that of any of the lists: I can click "Add another Item", and a set of all three of these fields will appear.
I have a vague idea of how this can be executed, but it involves using the form API to add fields before the form renders each time, as well as the necessary AJAX behavior. This seems a bit overcomplicated, since this would also necessitate creating an additional DB table to hold these tacked-on fields.
Is there a relatively simple way of doing this solely through hook_install()?
You can use drupal.org/project/profile2 or you can complete it using standard Drupal functionality, i.e. create a content type named, let's say, 'myprofile' and add all the fields use need. Then add a nodereferece (http://drupal.org/project/references) field to the user standard profie that would point to your 'myprofile' content type.
So all the 'myprofile' content, created by that user would be his profiles and the one pointed in his standard profile will be his default.
I hope it's clear enough )

How can I have one content type be a child of another content type in Drupal?

I would like to create a new content type Family in drupal. I would then like for that content type to have fields which ask you to choose from a list of Child where Child is another custom content type.
Furthermore, I'd like to restrict the choose child field to only show children for which content has been created.
Example: I'd like to create a new Family based on the Family content type. Then while I'm creating the family, I'd like for it to ask me what children I want, and I can choose from Bob, John or Sarah all of which are previously created content of content type Child.
I installed the Relation module but I don't understand how it works so I'm not sure if this is what I need or if I can achieve this somehow with taxonomy or something in Drupal core.
I'm not sure about the Relationship module as I have not used it, but it is definitely worth your time to look at the References module. This is pretty much a port of the node reference and user reference field types that were a part of CCK in Drupal 6. It installs new field types you can use in your content types.
Once you install the module (be sure to install Node Reference) you can add a node reference field to your "Family" content type and allow it to only reference nodes from the "Child" content type.

Resources