Importing HTML into TinyMCE using ColdFusion - coldfusion

Hey everyone, I would appreciate a pointing in the right direction with the problem I'm having. In short, I'm working on an application that will create PDFs using TinyMCE and ColdFusion 8. I have the ability to create a PDF by just entering in text, pictures, etc. However, I want to be able to import an html template and insert it into the TinyMCE .
Basically, I have a file directory code snippet that lets me browse through my 'HTMLTemplates' folder, and am able to select an HTML document. Now, I want to be able to take all the code from that selected HTML document and insert it into my TinyMCE box. Any tips on how I might do this, maybe?
Thanks!

If I understood you correctly, you already have a TinyMCE plugin which pops up a window and allows you to browse the certain directory using existing cfm page which you render within the popup window. Right?
If not, you should start with this. Not sure how easy it is done in current version, but in the older TinyMCE I've created the custom upload plugin (needed to track the site security permissions for current user) pretty quickly.
Next, I can see two quick ways to pass the server file contents to the client-side:
Make it available via HTTP so you can make the GET request and read contents into the variable.
Output it on the page using CF (say, on form submit when file selected) and grab using JavaScript.
I'd personally tried the second option. After you grab the text into the variable you can put it into the TinyMCE using it's API.
It can be as simple as output escaped text into the hidden div with known ID and read it using DOM operations (assuming that there is cfoutput around):
<div id="myTemplate">#HTMLEditFormat(myFileContents)#</div>
Also you can output the text directly into the JavaScript variable (of cource, with accurate escaping), maybe like this.
<script type="text/javascript">
var text = '#HTMLEditFormat(myFileContents)#';
</script>
Most advanced and possibly better for performance (and definitely "cooler") way is to use the concept of script tags as data containers, like this:
<script type="text/plain">
#HTMLEditFormat(myFileContents)#
</script>
Last time I've seen this in Nadel's blog, I think. Read it, pretty interesting.
Hope this helps.

Related

Sitecore 9 - Add an Image to a Link in the Footer

A client is using Sitecore 9 - we are not Sitecore developers.
We've been asked a simple thing: add social media links to the Footer of their Sitecore site.
Its proving more difficult than expected.
I've added the links on other pages by editing the HTML directly via the WYSWIG editor.
But the Footer appears more restricted, only accepting the addition of templates like 'Link'.
The 'Link' template has an option to add an external URL but doesn't have an option to add an image.
The CMS looks like this:
Is there any way to add a link, with an image, via the CMS (without the need to write Sitecore code), so the page chnages from this:
to this:
If you dont want to write Sitecore code, maybe you should think about using frontend.
Find the views that holds the footer (probably Foundation/Footer.cshtml) or something like that.
-To easily find where it is, follow these steps
Go to a content page Presentation Details that has footer (probably any)
Go to Controls
Find the footer rendering in there
Click on it
Grab the Datasource's value
Go to the Datasource's path
There should be a field holding the value of the view.
Add some css class on the div that holds those items, and do your frontend stuff in there...
It is not a scalable solution, so I would highly recommend updating the Footer rendering by adding new fields and adapting the model/view. So that way a content editor could easily add a new value for each socials.

How to make input box work in the result page

I am learning Django and i learn on making small project for lEARNING PURPOSE.
I learned how work with input and use as variable. Now i want to use search box with the same principle.
Please see the link of input based :
https://stackoverflow.com/questions/58813945/changing-form-to-search-box
index.html is the input after inserting info and clicking ok it directs to index2.html which shows the results
What I need to change besides POST to GET to make it work as it works with input function? do i need to change form, models?
My concern also i want to inset search bar in the navigation in index2.html where user can make search from the result page. This is my index2.html page. I tried to put {{form.as_p }} inside the form function but it does not work. I want after putting infro in search box and clicking search glyphicon (which does not work) will stay on the same page index2.html
I searched the internet and read stackoverflow other examples, but they use complicated version, i need a simple one :
1. i want to have search box on index.html page so it does not show me the name in front of input box and
2. i want search box in the index2.html page keep implementing the same function as index.html so a user do not have to go the initial page to search new data.
Any help or tips would be highly appreciated.
Since you're using bootstrap4 I would recommend to use its template tags and form field customization options.
Example:
{% bootstrap_field form.login show_label=False addon_before='<span class="fa fa-user"></span>' %}
Not: this example uses Font Aweseome for icons.
Also you're not using the real power of Django Bootstrap4, see Quickstart. You can always override the version of Booststrap or the CDN used in your settings.py if needed: Settings.

How can I create a plugin to insert templated html within a text plugin in Django CMS

I'm fairly new to Django CMS so please forgive me if my terminology isn't right.
I have a page with a placeholder within which I have added some html using the Text plugin. Within that, I would like to be able to add one or many pre-templated pieces of html.
I have looked into building my own plugin but the documentation that I've been reading here only allows the plugin to be added from outside the actual text plugin page and renders the result beneath my text plugin content. I've found the section on Nested Plugins, but I'm trying to nest my plugin within the built-in Text plugin which that doesn't seem to cover.
What I'm looking for is to be able to build something so that it places block-level html elements within the content like the Link or Image plugins (in my case, it would be some block-level html content).
How can I do this, or where can I find some more information on how this can be done?

Jquery inside of CFDiv

I have a page that includes a CFDiv tag that displays content from another file.
<cfajaximport tags="cfwindow,cfform,cflayout-tab,cfdiv">
<cfoutput><cfdiv class="vehicle-log" bind="url:trip_tab.cfm?ticketid=#ticketnum#" ID="theDiv" bindOnLoad = "true"/></cfoutput>
The external file has jquery tabs and jquery datepicker. None of the jquery seems to work in the CFDiv. If I call the external page by itself, everything works fine.
The reason I'm using a CFDiv here (I know most people hate cf layout stuff) is because the external page has a form element that I can submit and add to data to the db without refreshing the whole parent page. This is the only way I know how to do this.
Anyways, does anyone know how to get my jquery elements to work in a CFDiv?
Thanks.
Brian
You've got more than one problem here. First, you are using <CFDiv>, which under the covers is using portions of a very old version of ExtJS. So you are likely going to run into some headaches with mixing ExtJS and jQuery (and jQuery plugins).
Second, since <CFDiv bind="..."> uses AJAX to load the external HTML window content, you would need to change your JavaScript strategy. <CFDiv> will not pull in and execute the JavaScript code (including jQuery) from the external page (trip_tab.cfm), unless you only use CF UI widgets inside that external page (then the <cfajaximport> tag handles that for you). It only loads the HTML DOM content. You will have to move any <script> and <link rel="stylesheet"> tags and custom JavaScript/jQuery code and CSS into the parent page (the page that has the <CFDiv> tag in it). Then you'll have to find a way to listen for the AJAX event (completion of loading the external page) and call the custom JavaScript/jQuery code.
As others suggested in the comments above, using <CFDiv> is only making things harder for you. If you switched to using one JavaScript library for your UI components (like jQuery/jQueryUI/jQuery plugins), and put all of the necessary code into your main page, what you desire can be accomplished fairly easily.
I found a simple work around... CFdiv creates what feels like a seperate browser window, but its not actually one. So it can't pull Javascript files in via:
<script type="text/javascript" src="/js/scripts/jquery-1.11.1.min.js"></script>
The above is telling the browser "go fetch this file" - but since your CFdiv is not really a browser (Its a controversial permutation of CFajax as described here) it doesn't do it.
Technically, the above makes the browser include it into the page, just as if you cfincluded it , or just pasted the Javascript in there.
So convert the above to:
<script type="text/javascript"><cfinclude template="/js/scripts/jquery-1.11.1.min.js"></script>
And included javascript will work! (provided there aren't any conflicts with cfajax et al)
I had a similar problem in that my jquery was not working, and doing this fixed it.

Opencart module development - Inject javascript/html code in some pages

I'm a beginner on Opencart and just started developing a module for Opencart which it must inject some lines of javascript and html code in these pages:
- Cart Page
- Product Page
- Confirmation Order Page
- Register form page
The official documentation doesn't have informations about how can i do that, I've tried to find a good documentation about OpenCart but I didn't find anything.
I need help. How can I do that?
Diggin necro topics;) :
The easiest way i think:
upload/catalog/view/theme/[themename]/template/product/product.tpl - here you can add your custom html for product page
[your theme name, you shouldnt overwrite default theme because it can cause damage after update]
It depends on where you're trying to insert the HTML/JavaScript.
Doing things the proper way in OpenCart, you're limited to the column-left, column-right, content-top, and content-bottom positions.
The files you'll need to create are:
admin/controller/module/mymodule.php
admin/language/english/module/mymodule.php
admin/view/template/module/mymodule.tpl
catalog/controller/module/mymodule.php
catalog/language/module/mymodule.php
catalog/view/theme/default/module/mymodule.php
To learn how to do this the first time, it's easiest to replicate an existing stock OpenCart module (preferably a simple one, such as information). Once you've replicated it you'll need to go through each of those files and replace any references to "information" with "mymodule".
After that, if you've done it properly, you should be able to navigate to Admin > Extensions > Modules and see your module in there. Then install it, use the "Add module" button to position the module on all the relevant layouts, hit save and hey presto you have a working module on the front-end.
To modify the front-end output, just edit catalog/view/theme/default/module/mymodule.php
If you want to insert your HTML somewhere other than the 4 available positions OpenCart gives you, position your module in the content-bottom position and use JavaScript/jQuery to inject some HTML where you want.
If this is for your own personal website then as Pawel S suggested it would be easiest to simply modify the relevant view files (ie. catalog/view/theme/[themename]/template/product/product.tpl), however if you're making a module which you plan to distribute then this should be a last resort.
Hope that helps!
I realize this is probably long dead by now, but if you're creating a module that needs to modify existing controllers, languages, models or views the correct tool to use is vQMod.
vQMod allows you to modify existing code on the fly using XML.
https://code.google.com/p/vqmod/