ACF - category field data to its containing posts/pages - categories

I am trying to find a general way to bring the field data of a category to the posts in this category.
My categories have fields like "e-mail", "adress" etc. and I can show this data on the category pages. It would make sense that the posts/pages assigned to a category somehow inherit the field data of their parent category.
Is there a way to achieve this through functions.php or some setting?
Some help would be greatly appreciated. Thanks!
Cheers, Markus

I am pretty sure you would have to do a separate query in the post/page template to get the acf field data associated with the category of the posts/pages.
You could make this into a function. You would send the categories from the template page for your posts or pages to this function and get the template to assemble the acf metadata.

Related

How to set display value in SAPUI 5, SmartField Value Helper field.

Hi: I am looking at the standard SAPUI 5 Smart Field demo:
https://sapui5.hana.ondemand.com/#/sample/sap.ui.comp.sample.smartfield/preview
I would like a field with a value helper, such as Currency on this screen, which displays the field description inside the input box instead of the field id.
Example:
Change the Category field from combo into a value helper (popup)
Get the field to display the CategoryName - or from the related table the LTXT field instead of the ID.
HowTo
That is easy: delete the line
from the metadata.xml file.
??? I have tried many, many things.
I doubt that anyone will reply, because there is most probably no good answer.I do not find this good functionality.
I think that I will need to change my ID field values for popup (value helper) fields to Description (ID) . Description need not be unique (one can have two relations to the same company with different ID's.)
By doing this we also "fix" the problem with the search ODATA command which searches the ID field. Of course users will want to search the descriptions.
In general SAPUI's value helper is not great. It is normal practice to use numerical ID's and descriptive descriptions. The description should be displayed and searched and not the ID. I found their filter generator on the popup screen nice - it is not all doom.

How to Display Attribute Group Name in Product Tab Magento 2.1.3

I created an attribute set and attribute groups with attributes in it. In the admin panel the attributes are listed in groups, like i created them. But on the front productpage all the attributes are listed together, without displaying the attribute group name first.
I would like to display the Attribute Group Name on the product page (more information tab), before the attributes in this group. How do i do that?
There is no way to do this by default in Magento 2.
There are a few ways I can think of to acheive this. Perhaps best would be to extend the getAdditionalData() method in /Block/Product/View/Attributes.php so that it adds the attribute group name (or id) to the returned array.
You would then need to create a local copy of Magento_Catalog/templates/product/view/attributes.phtml and iterate the array returned by the modified getAdditionalData() method sorting it according to the group name and then output the data with group name headings.
I'd be interested to hear of other or best practice approaches to this type of relatively simple extended functionality in Magento 2.

n-n relationships for multiple content types

I'm working on a project based on Laravel 5.3 and Backpack CRUD. My project has about 8 different content types (news, page, portfolio, events, team, video, gallery, jobs).
I need to be able to add tags to every content type (n-n), and every content type has its own specific tags, so tags are NOT shared between the content types.
If I want to use the select_multiple or select2_multiple field type, I would need 8 tables for the content itself, 8 pivot tables, and 8 tables for the tags(!).
Obviously I would like to have just one table for the tags, but if I use the select_multiple or select2_multiple field type, I get all tags in the edit-form of every content type.
So, my question is: Is there an elegant way to filter the results of the select_multiple or select2_multiple field type?
I have created a simple schema with two content types:
http://dbdesigner.net/designer/schema/60412
In this example I want to be able to filter the tag list on content_type_id, when I'm editing the content of news or page. So I just want to see the news tags in the news-edit form, and just the page tags, in the page-edit form.
Or maybe I should just use the select_multiple field type as intended, and accept the 8 tag tables(?)
Any help or advice would be greatly appreciated.
I think a clean way would be to:
create different models for each tag use, so NewsTag, PageTag, PortfolioTag etc. that would only extend the Tag model and use a global scope to filter the results after content_type_id;
use backpack select2_multiple fields with NewsTag, PageTag, PortfolioTag etc; anything you set on the Tag model will be used (including the table attribute, mutators, accessors, etc);
Cheers!

Manual sorting of sys_category

On my TYPO3 7 site, i'm not able to choose an order to the categories of a page or a news (plugin tx_news). I can only choose what categories that page or news have, using the checkboxes to select them.
Is there any configuration for that?
Alternatively, I may override these fields with my own TCA, but have no ideas on how to get a sorting tree of categories. Any hint?
On my sites running previous TYPO3 versions with tt_news plugin, its category tree allows to change the sorting after selecting the categories.
I coudn't find anything about it on the "select" documentation (https://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Select/Index.html). Looks like MM relations doesn't support sorting.
Does anyone knows how to get it?
Make sure you have the "extended view" checked at the end of the page. You can then sort the sys_category-entries using the up/down arrows.
If you need to sort your categories per item and not globally then a default MM relation will not work as it doesn't support sorting. You're on the right track. Override or extend the TCA, don't specify a MM relation and don't use the tree view rendering. Use a standard select like you would select pages. This should store the values as a comma-list string in the database and so represent the sorting like you would see it the backend.

Multiple records of model in a single form

I would like to create a form which works in the connection table between a "M:N" relation.
So the user is able to add multiple rows of a parent model in one form.
Can some help me to bring this working? What should be the associations?
My problem is the same like here.
Thank you very much for your help!
Looks like you are trying to do some nesting have you tried these tuts from railscasts
http://railscasts.com/episodes/196-nested-model-form-part-1
http://railscasts.com/episodes/197-nested-model-form-part-2
Also checkout this for some guidance on the types of relations you want
http://railscasts.com/episodes/47-two-many-to-many
You could always do that manually inside the controller without rails' form_for helper.
Thats actually what the second part of the answer to the question you linked to suggests.
Just like the answer mentions, giving <input> fields names ending with [] (e.g. <input type="text" name="field[]">) results in that field being an array in the params hash inside the controller.