Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Quick K# macro help View modes: 
User avatar
Member
Member
robert-pulldigital - 7/12/2013 10:41:27 AM
   
Quick K# macro help
I've been playing with various macro commands.

The last one I want to implement and haven't yet been able to achieve is to populate an editable text area with one column from results in a sqldatasource.

I'm thinking it's not going to be possible but it might be possible to perhaps bind the sqldatasource to a standard kentico repeater and use the macro language to select the first row first column for instance.

So in short can I write a macro in the CMS which is binding to a datarow in a sqldatasource

Thanks

User avatar
Member
Member
kentico_sandroj - 7/12/2013 7:47:54 PM
   
RE:Quick K# macro help
Hello,

May I ask where you would use the value if you were able to retrieve it with K#? I will have to check if this can be done with K# but I'm pretty sure you would have to create a custom macro.

Regards,
Sandro

User avatar
Member
Member
robert-pulldigital - 7/15/2013 4:02:51 AM
   
RE:Quick K# macro help
Thanks yes, the goal is to have an editable text area that is a lot like a letter which is customised depending on the logged in user. The datasource queries a 3rd party DB for values and these are to be used on the page. The control in use is an editable text area, the customer sees a nicely formatted letter signed by them etc. Based on the data in the sqldatasource however I haven't been able to work out how to get the values from the datasource into the editable text area

Thanks

User avatar
Member
Member
robert-pulldigital - 7/15/2013 4:04:09 AM
   
RE:Quick K# macro help
If I was to write a custom macro, for which the framework is now in place. From the custom maco how do I gain access to the SQL Data Source on the current page from the code.

Still new to Kentico but it gets better every day.

User avatar
Member
Member
robert-pulldigital - 7/15/2013 8:58:29 AM
   
RE:Quick K# macro help
It looks like it's not possible, at the moment the macros are resolved the context shows the page to be portaltemplate.aspx and doesn't contain the datasource control i'm looking for.

I still need to access a datasource control from a macro if possible as the users do not have access to the ascx transformations.

User avatar
Member
Member
kentico_sandroj - 7/15/2013 2:44:04 PM
   
RE:Quick K# macro help
Hi Robert,

Thank you for clarifying the requirements. Was the purpose to be able to edit the datasource output in the Editable Text Web part? If so, you would have to develop a custom Web part.

Optionally, you could use the Custom Table API to store the information from the datasource then you could create a custom macro that reads that information anywhere in the system.

Please let me know if you have any questions.

Thanks,
Sandro

User avatar
Member
Member
robert-pulldigital - 7/16/2013 4:14:58 AM
   
RE:Quick K# macro help
I want to be able to access controls on the page from a macro

So if there is a label with an id of lblName I want to be able to write <% lblName.Text #%> and have it translated to the text value.

In this scenario we have a sqldatasource on the page and it's populated from a 3rp party database and we want to be able to say <% sqldatasource.firstname #%> to get the first name column from the first row of data.

In a transformation we can use Eval("firstname") but the users are not going to be writing transformations, they want to use the wysiwyg editor so we are trying to either develop a custom macro or find the one that already exists that lets you access controls on the page.

The custom table is not very helpful as all the data is in a 3rd party Database and maintained there so ideally we want real time queries and I was hoping to utilise sql data sources to get the data and macros for display purposes.

Cheers.

Still looking for the right solution. We could write a custom macro for this but the way I imagine writing it means far too many database queries.


The final resort is for someone at the company to learn how to write and maintain a transformation.

User avatar
Member
Member
kentico_sandroj - 7/16/2013 7:25:10 PM
   
RE:Quick K# macro help
Hi Robert,

I discussed this with our consultants and they advised that the best approach would be using a custom macro which connects to the external db, cache the results, then use a custom macro method to specify which of the data-sources should be used and which of the results should be pulled (if the DS contains multiple rows).

Would this approach work for you? Please let me know if you have any questions.

Regards,
Sandro

User avatar
Member
Member
robert-pulldigital - 7/17/2013 4:37:18 AM
   
RE:Quick K# macro help
Yep that would work.

Thanks