Developer forum

Forum » Feature requests » Items: Source Type SQL with context values

Items: Source Type SQL with context values

Nuno Aguiar
Reply

Hi,

 

Would be awesome if we could integrate some context values in SQL querys. For example:

 - Set a dropdown list

 - SQL: "SELECT ParagraphId, ParagraphName FROM Paragraph Left JOIN Page ON ParagraphPageID = PageID WHERE PageAreaID = @Area(ID) AND ParagraphModuleSystemName = 'CartV2'"

 

Adding this field to a website, it would only have paragraphs with the Cart V2 module in that Website. The same logic could be applied for culture (language), pageID and whatever we need.

 

Nuno


Replies

 
Mikkel Ricky
Reply

Great suggestion. We could probably reuse some ideas from Context sensitive default values for item type fields – and maybe expand context sensitive default values to include multiple placeholders (as discussed during a webinar). We'll take at look at doing this.

Any suggestions on how to handle cases when the (example) query is executed in a context where @Area id not available?

 
Nuno Aguiar
Reply

Hi Mikkel,

 

I actually got the idea from the Context Sentitive values ;) It's the beautiful cycle of sharing ideas and inspiring each other :P

 

As for dealing with missing context, I see two options:

 - Since the SQL will return 0 rows, render an empty dropdown and/or with a "Nothing selected" option - the backend user and/or developer will need to look into it

 - Have a checkbox for the fallout, leave it empty, or clear the condition. In the example above, would list all Paragraphs with CartV2 - Maybe grouped by Websites (<optgroup>)

 

The first option prevent bugs and errors BUT if you have multiple context sensitive values, would make it a lot harder for the enduser to find which context value it is.

 

Nuno

 
Nuno Aguiar
Reply

Hi Mikkel,

 

Was this developed?

 

Nuno

 
Mikkel Ricky
Reply

No, it hasn't made it (yet). There are some technical challenges with doing this, but we understand what you want to be able to do and it still makes sense to be able to use some context values in source sql queries.

In related news, in Dynamicweb 8.5 it will be possible to use "Select items from current area" and "Select items from current page" when using items as source for lists. This is not quite what you request, but it will solve many issues to be able to limit the items in the lists to the current area or page.

Best regards,
Mikkel

 
Nuno Aguiar
Reply

HI Mikkel,

 

Thanks. I am sure it will address a lot of situations.

 

Best Regards,

Nuno