third party database content lessons/examples
I need to include dynamic content from an external database. What's the recommended approach and are there any lessons/examples?
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by jim.lorenz on 24 Aug, 2015 06:30 PM
ok, I've found some other discussions but none of them are current. Plus the references to web services and feeds seem way to complicated. Embedded code seems like most straight forward (asp.net). However, what's the current recommended practice? Any complete examples?
Support Staff 2 Posted by Tim on 25 Aug, 2015 03:13 PM
Hi Jim,
There are a few different ways you could potentially do this (as you noticed), but if you are just looking to grab small bits of content from your external database then I agree that you can look to embed code within the content of your pages. Doing so will require that you make use of passthrough code sections to surround your asp.net code snippets. The end result will be that the external content will not be displayed within Cascade, but will be displayed once published to your .NET web server(s).
For example, your code snippet might end up looking something like this:
As far as best practices are concerned, it's generally best to include these types of code snippets within Blocks and/or Formats as opposed to entering directly into a WYSIWYG editor. The reason for that is that since most end users don't have the ability to edit the HTML source directly, they could unintentionally delete this code without ever knowing it was there (since the passthrough code sections are essentially HTML comments that won't appear in the rendering).
If you do go the .NET route, you'll also need to add your .NET header to your Template(s) using the passthrough-top code sections.
I looked around for some examples of this but wasn't able to find anything. I'm sure other folks have done something similar so perhaps they can chime in here, but in the meantime feel free to comment back with any followup questions and I'll do what I can to provide more recommendations.
Thanks!
3 Posted by jim.lorenz on 25 Aug, 2015 09:26 PM
Hi Tim,
Thanks so much for your attention. It’s too bad there isn’t a way to write a custom index which accessed the external db and returned an xml result set.
Cheers
Jim
Support Staff 4 Posted by Tim on 25 Aug, 2015 09:30 PM
Hey Jim,
No problem.
Does your external database have an option to produce an XML file that you can place on a server somewhere? If so, you could easily do the following:
Let me know if this helps! This is a very common method of consuming external content and working with it inside the system.
5 Posted by Bryce Roberts on 26 Aug, 2015 12:38 PM
You can write either custom XSLT with an extension or Velocity format (reflection) to return to the transform context an JDOM object. You can directly output this into the page and transform again with a page level XSLT, or you can continue to process the object.
6 Posted by jim.lorenz on 26 Aug, 2015 02:16 PM
Bryce,
This sounds interesting. However, as a Cascade “newbe” I don’t understand. I am writing my own XSLT at the page level and I can code c# aspx. I’d really appreciate seeing an example or even a diagram of your approach would help.
Cheers
jim
7 Posted by Roberts, Bryce ... on 27 Aug, 2015 02:12 AM
Hello,
Some example code:
8 Posted by jim.lorenz on 27 Aug, 2015 12:15 PM
Thanks guys – I’ll study, and hopefully learn from, this.
Cheers
jim
Support Staff 9 Posted by Tim on 27 Aug, 2015 02:42 PM
Thanks for chiming in and providing that example, Bryce!
Jim, let us know how things go and certainly reach out here again if you come up with more questions. Have a good one!
Tim closed this discussion on 27 Aug, 2015 02:42 PM.