0

I'm creating and extension to assign a determinated width to a component presentation in order to show it filling X columns inside a container. The original idea is to be able to repeat this process to all components presentations.

Could you tell me if i could do this without using coreService? Is there any way to do this in the component template or page template?

My idea would be to store data with the page template code in the saving moment (using AppData) and retrieve this information when the page is loaded again.

Its possible to get this information in component template code?

Thanks in advance!!

1

1 Answer 1

1

I presume you've considered creating different templates specific to the presentation/output required and deemed it not appropriate (e.g. presents more options than necessary to an editor/to manage).

Is there any way to do this in the component template or page template? - Read it = Yes, Write = Not without a changing a specific setting that's there to stop Page/Component Templates updating the state of content.

What do you mean by "store data with the page template code"? - I presume you mean trying to have this embedded into the Template script - which I would not recommend, the Page Template should be used to generate the necessary output for the page and not to input data back into the system.

I guess you could use the Event System (Page>OnSave) to push app data into, say, the Component(1) that would contain a field pertaining the to the specific instance of Component AND Component Template AND Page IDs (assuming the same presentation won't be used on the same page with a different column value).

Then, when writing your output, you can catch the AppData and add the necessary syntax to denote columns for that instance of a Component Presentation (be that in the Page of Component Template - depending on how you have to write this out etc.)

Update

Just reviewing this and thought it worth adding the SDL Idea (and I'm sure someone did an extension) of having specific fields that apply to an instance of a CP - sounds like this would actually be a good fit


(1) you could equally use the Page but it may be useful to hold it in the Component in the event you want to report on total usage of that asset - which would mean only opening a single item, the Component, as opposed to looking at where it's used

2
  • Thanks for giving me your knowledge Dylan. But i just see another posible solution: In the component presentation tab i could put a user control (with radio buttons) and communicate with the table App_Data throught Core Service Client. On the other hand, in the template component code i can write a function using TOM.NET to retrive this data and use it to display correctly my components. Do you think is a good option? The problem for me is this solution is valid is to know the parameters to pass to the functions (coreservice an tom.net). Thanks in advance!! May 22, 2017 at 16:58
  • This doesn't seem different than the suggestion above. (1) A method for the editor to denote columns, (2) A method to save that data - you're suggesting a coreservice call (presumably within your extension) but I'd suggest tying this to an event (3) Template (page or component) retrieves value on rendering output. May 23, 2017 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.