Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Umbraco Flavored Markdown to handle block grid expression in a block list/grid and extract expressions from data source #2345

Closed
wants to merge 13 commits into from

Conversation

IbrahimMNada
Copy link
Contributor

Description

When Creating a block list that contains url picker at the block list label, it shows only the document type alias.
which is not very helpful like this :.

image

so using Umbraco Flavored Markdown I have developed a new markdown that enable us to see what ever expression we put inside of a block list label:

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Motivation and context

When Creating a block list that contains url picker at the block list label, it shows only the document type alias.
which is not very helpful.

How to test?

Go to the list configuration at the label section add
{@<url-picker-alias>[<target-index>].<prop-alias>} exmaple : {@mainNavigation[0].name}

Screenshots (if appropriate)

image image

Checklist

  • If my change requires a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@IbrahimMNada IbrahimMNada mentioned this pull request Oct 7, 2024
7 tasks
@iOvergaard iOvergaard requested a review from leekelleher October 7, 2024 09:32
@IbrahimMNada IbrahimMNada changed the title Adding Umbraco Flavored Markdown for url-pickers in a block list/grid and extract expressions from data source in general Adding Umbraco Flavored Markdown to handle block grid expression in a block list/grid and extract expressions from data source Oct 7, 2024
@IbrahimMNada IbrahimMNada mentioned this pull request Oct 7, 2024
4 tasks
@leekelleher
Copy link
Member

leekelleher commented Oct 8, 2024

@IbrahimMNada Thank you for your PR, I'll review it and feedback in due course. 🙏

In the meantime, since Umbraco 14.3, there is a content-name UFM component that may provide what you need, try {~mainNavigation}.

The idea of that specific component is to take a unique ID (or array list) and query the document (or media or member) repositories, then concatenate the names together by comma. This should work for the Content/Document Picker and Multi-URL Picker property-editors.

@IbrahimMNada
Copy link
Contributor Author

Thank you for your response,
i tried to make it as generic as i could in the context of bloc-list
not only for url content picker.

this could help by giving full control over the label. if you want to expand it on more than grid list
please tell me im pretty sure we can agree on something

@IbrahimMNada
Copy link
Contributor Author

@leekelleher
Copy link
Member

Hi @IbrahimMNada, thank you again for the time and effort you've put into this pull request. 🙏

While I do understand the reasoning to use JavaScript syntax style to traverse down into the property data, this may lead implementors believing that other JavaScript expressions may be evaluated too; (e.g. as seen in the linked forum post example, {= bodyText.replace('foo', 'bar')}).

Support for an JavaScript eval()-esque feature isn't a goal for Umbraco-Flavoured Markdown (UFM), as there are potential performance and security concerns around this. Of course, we do want to UFM to support common scenarios, in more generalized ways. e.g. see the UFM filters feature for v14.3.0.

With that said, I have chatted with several people in the community who are wanting to do similar with UFM as you've offered here. Have you considered making an Umbraco package for this? It would also qualify as a Hacktoberfest contribution.

I hope this isn't too disheartening, I'd encourage you to pursue the package creation path. I could see it becoming popular.

@IbrahimMNada
Copy link
Contributor Author

No this is not the case I do not use eval at all its simply walk through an object that's all

I don't know man you can check the function

@leekelleher
Copy link
Member

leekelleher commented Oct 10, 2024

@IbrahimMNada Sorry, I know the code here isn't using eval(), (I see the regex pattern). 👍

My point is that if we offer support for syntax like mainNavigation[0].name, this is JavaScript array and property accessor syntax, so may open the suggestion that other JavaScript expressions are supported (which they are not), so more features get requested (in time) and it'll eventually become similar to eval(). Which isn't something we want to support in the core for UFM.

I still think this could be the basis for an awesome package.

@IbrahimMNada
Copy link
Contributor Author

Thanks brother , no worries !

@IbrahimMNada
Copy link
Contributor Author

hello ,
following your recommendations.

check out this new package :https://marketplace.umbraco.com/package/umbblocklist.dyanmiclabels

The (Dynamic Block List Labeling package) for Umbraco enhances the default block list by enabling dynamic, customizable labels. Instead of using static, predefined labels for block list items, you can now define labels that dynamically adapt based on the content of each block. This is especially useful for identifying and managing multiple entries in your block list, providing a more streamlined and user-friendly experience.

@leekelleher
Copy link
Member

@IbrahimMNada Super, thanks for the update! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants