Shopware: Injection of JS library on FE - plugins

I'm new to shopware and currently learning plugin development. I'm creating a plugin that needs to load a JavaScript library to be loaded only in PDP and it needs API credentials from the database.
The docs cover how to load JavaScript via JavaScript plugins but I need to fetch data from the BE, are there any docs covering this topic or how do I start implementing this feature?

To make (mostly static) data - like a API configuration - from the database available in the Frontend Javascript code, you can print out that data in the Twig template. The Shopware core assigns such data to the window object. You can do the same in your plugin.
To do this, you also have to "transport" the data first to the the Twig file, like described in another doc page.

Related

Integrate existing TouchUI component into RTE - AEM 6.1

I'm looking to see if it's possible to integrate an existing AEM Component that I've developed (lets say button component) into the RTE.
I've read the following blog posts
http://experience-aem.blogspot.com/2015/01/aem-6-sp1-touchui-richtext-editor-color-picker-plugin.html
http://experience-aem.blogspot.com/2015/09/aem-61-touch-ui-rich-text-editor-rte-browse-insert-image.html
I've also read the documentation (which is non existent).
I'm not looking to recreate the exact same component just for the RTE, this would need us to maintain two separate code bases, recreate the custom logic we have in the already existing component which has been tested and automation.
But most of all, go against best practices as we want everything to be agnostic.

EPiServer migrate content from home grown CMS

Hopefully someone can help me, I'm new to EPiServer and have been given a data migration task. We are using the latest version 8.5. I need to migrate content from a clients home grown CMS (that luckily is in a tree like structure) to EPiServer. There doesn't seem to be a whole lot of information about this on the web - perhaps I just don't know the right thing to search for.
It looks like using the EPiServer.ServiceApi might be the route to go but again locating useful documentation is proving difficult.
I was thinking of setting up the client CMS in SQL Server and writing a simple console application to call the EPiServer.ServiceApi inserting the content. If anyone has any information on this or better still and example i would be very grateful.
Thanks,
Dan
If you are just importing content from another CMS I would write a scheduled job in EPiServer:
http://world.episerver.com/code/dannymurphy/Stoppable-Scheduled-Job-with-feedback/
That job then uses the standard IContentRepository to create content:
http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/8/Content/Persisting-IContent-instances/
That way you can run it whenever you want and have access to EPiServers complete API. Also you can see progress of the import through the job status.
In the job you can read the content as a file in any format you like or directly from the source CMS database or some xml or RSS feed perhaps.
I have moved content from PHP, Java and .NET CMS this way. In .NET you could even access the source CMS via WCF or SOAP if available.
The ServiceApi is relatively new and more focused on Commerce products and media assets rather than CMS page and block content so I wouldn't use that.
There is complete documentation below for the ServiceApi by the way, did you not find it?
http://world.episerver.com/documentation/Items/EPiServer-Service-API/
Regarding language management you can read more in the below links:
http://cjsharp.com/blog/2013/04/11/working-with-localization-and-language-branches-in-episerver-7-mvc/
http://tedgustaf.com/blog/2010/5/create-a-new-page-language-branch-programmatically-in-episerver/
Basically you have two options for multiple languages. If the content is just straight translations you should create nine different language versions (branches) of the same page. You can also have multiple sites in an EPiServer installation but that requires 9 separate licenses (and the associated costs).
I've done a lot of EpiServer content migration projects. The easiest way if it's possible is to export your current sites tree in Json and then import that into EpiServer. I've had to do it on a recent project and mixed with Json.net it's pretty easy.
If you want to go that route you can find all the code to do it here: EpiServer Content Migration With Json.Net/

JST Template Engine with Slim & Coffeescript

This wiki page explains how to create a directory of Javascript templates that can be accessed from a JST object in the DOM:
https://github.com/marionettejs/backbone.marionette/wiki/Using-jst-templates-with-marionette
JST stands for Javascript Templates. This feature — available by default in Rails 3.1 (see notes)— allows you to distribute your Javascript templates as ready-to-use functions in your scripts.
This mechanism is very useful because it avoids having to download templates asynchronously or to distribute them in the source code of your pages.
(Please refer to the post for further info)
The example template engines given include pairing simple HTML with embedded Javascript and Coffeescript, and HAML files with embedded Coffeescript.
I am wondering if there is a similar template engine available that uses Slim and Coffeescript, that would allow me to achieve the same result.
For those interested, I have found an engine that does what I was looking for: https://github.com/jfirebaugh/skim
It's specifically for rails projects (for the time being), but enables the creation of Javascript Templates using Slim.
It's similar to haml_coffee (https://github.com/netzpirat/haml_coffee_assets), just uses slim instead of haml

Web based plugin architecture for simple user interfaces

I have a web based application using Primefaces with a very basic plug-in like architecture. The configuration of these plug-ins was all handled with xml, which is not so user friendly system.
I would now like to allow for each plug-in to be configurable via the web application, what are my options?
I have looked into Portals and Portlets but that seems like a rather big change to my application and my plug-ins do not require such complex user interfaces, a textbox or two of configuration is more than enough.
Does anyone have any suggestions or advice and what would be the best route here?
Create a simple page , per plugin that read the XML file, parse the option that you want to change , present it to the user with a simple interface, and save back the XML file.
Take care of the saving part and password-protect this page!

Creating a Calendar in Symfony

I'm using symfony 1.4 for my web project.
I have the following problem (or opportunity): I need to create a calendar where the "common" user has only the ability to see (or read) the date and time of the events and the "admin" user can edit, add and remove new events. So it's basically a google calendar type of thing where I have to different permissions, read and read, write, delete.
Also I need to be able to fully customize a calendar style so that It matches my css.
How would your approach this problem? I've been trying to find the best plugin for this endeavor but I haven't found one that with a good documentation
Thanks in advance!
I recommend FullCalendar jQuery plugin. It gives you very nice JavaScript calendar with drag&drop support. You can use your own CSS style.
On the server side create symfony actions that will return data to FullCalendar API. Just serialize the data to JSON Event Object.
Of course you should use symfony security component to restrict read/write access. Show only those events that users should be able to see. And don't let them access write actions if they don't have write permission.
To manage event data you can either create backend admin module or display your own form when user click on calendar (like Google Calendar does). If you like the second approach then you have to handle it in JavaScript.
I would suggest to build 2 applications for that.
frontend (read/see)
backend (admin)
Just go with the normal symfony approach.. define your models, generate frontend (inkl. modules). There you can adjust you templates and css.
Practicle open book where you can choose the topics you need
Then use the admin-generator to get the backend application. You can customize behaviours and styling of course.