Pulling s_categories table from database to someone.tpl in shopware 5 - smarty

I want to pull the data from the s_categories table in the database to the tpl file I want and use it as an array, but I couldn't find how to do this in smarty. (Note: {php}{/php} doesn't work.)

You can't do that in smarty, you need a plugin that provides this data to the template to use it there. Smarty is a template engine and should not be used for accessing data from the database - this is the wrong layer of the application to do such things.
All things are covered in the plugin startup guide: https://developers.shopware.com/developers-guide/plugin-quick-start/#search-results

Related

Learning Laravel blade standalone

I'm pretty new with blade template building in Laravel and I'm planning to use it as standalone. What's the best way to learn blade template building perhaps for standalone?
What's the different components of blade template building and what's the data flow?
If you want to use without Laravel, then you could try my library.
https://github.com/EFTEC/BladeOne
Its stand alone, only one class and no dependencies (and mit license)
The docs about blade is here
https://laravel.com/docs/5.5/blade
The data flow is simple:
add all the libraries and dependencies.
creates all the
variables, collects information from $_POST,$_GET and such.
Load
and do all the operations, such as loading from the database,
inserting, doing some operation.
And finally, call the template and send the variables. The template must be called at the end of your script. Always.

what is the correct approach in order to host / integrate / show my existing MVC3 project inside orchard?

I've an existing MVC3 project that implements a certain functionality, this project has it's own views, and a separate Database.
now I'm required to use the same functionality inside one of my orchard project,so I thought that I can host this solution in somewhere and view it inside an iframe or something.
Am I thinking right?,
is this the correct step to take in order to achieve this requirement inside Orchard?
to make it more clear, all I need to do is to view this solution and interact with it's controls and views from a hosting page inside orchard, and the subsequent requests should be handled by my solution in order to hit it's own data store and get back with the requested data in order to be displayed to the user.
any help would be appreciated.
Update:
thanks for Bertrand Le Roy for his answer, I can now view my solution inside my
orchard website.
I came in to one more HUGE problem, which is that my application can no longer connect to my external database.
I've a DB that is hosted in some where else, and I'm using EntityFramework to deal with it.
the problem is that if I put the connection string inside my module web.config, or main orchard web.config, I run into several types of errors like:
"System.Reflection.TargetException: Object does not match target type."
or
"System.Data.MetadataException: Unable to load the specified metadata resource."
My question is: How could I pass my connectionstring correctly to my solution, assuming that I'm using Entity framework as my ORM.
Many thanks.
You will need to put it into a module.
You will have to move route definitions to a Routes.cs file (look at any existing such file for examples).
You will also need, in order to access your data store, to opt out of the ambient Orchard transaction around the data access code (using (var scope = new TransactionScope(TransactionScopeOption.Suppress))).
If you are using dependency injection, you may have some work to move that to the Autofac-based way of doing things in Orchard.
If you want your work to appear seamlessly in the Orchard admin, you may want to decorate your admin controllers with the Admin attribute. If you want your front-end to use the current theme, you'll have to add Themed attributes and maybe refactor your views so that they only emit HTML for the content zone instead of for the whole page.
Add a manifest (module.txt) to your module folder and you should be good to go.

MVC3 Dynamic SubDomain Routing

First of all, I have read a lot of post relating this issue like:
Asp.net MVC RouteBase and IoC ,
Tenant-specific routes for dynamically loaded modules ,
and many others.
What I want is:
- Dynamically create pages like tenant1.mydomain.com, tenant2.mydomain.com, etc.
- My tenants will have the same functionality but just different content, styles, title, etc.
I have tried extending RouteBase class but have read that is not a clean solution.
Then I have tried creating a custom RouteConstraint like above posts recommend but not succeded.
Help me!
Thanks!
I have achieved this by doing two things. 1) was to provide functionality to select the correct content by providing the repositories via a factory which was handed the URL on creation. The issue here is that it might be possible to fetch the wrong data via relationships from entities that themselves don't have a tennantid field.
2) Is a basic custom view engine which looks up the host part of the URL and would look for a client specific template (via a folder structure) if the template was found it was used, otherwise the default template is returned.
Between these two I've got a system that delivers (in my case) multiple websites via the same bespoke CMS and product management tool.

CodeIgniter input class outside codeigniter

I'm moving an app from flat file php to codeigniter and I'd like to integrate the two as much as possible before moving over completely. I'm looking to specifically use the input class outside of codeigniter but it looks like I'd also need to use the controller logic (to get access to input segments). Can anyone walk me through using the input library in a flat file php?
I think you're creating too much work and potential problems by trying to do this. You'll be better off if you go directly to CI. Move any standalone functions in your standard PHP files into Helper functions.
If you really want to do this, you could use CI and create controllers/functions for all your files, then in the controller functions, just include() your PHP file and ignore the models and view for now. That way you'll have access to all the CI variables, including the $this->input data.

How I can store custom values in Joomla's "Application context"?

I just finished to implement a custom functionality in one of the page articles in my Joomla website using sorcerer. In this page it is possible to query a hash and lookup it against a database.
I would like to store the last 5 queries and show them in the page but I don't know how to do it. I need something as Java EE "Application Context" to store this values and make them available to all the users so using a Session to store this values is not what I need.
I saw in the documentation that in Joomla exists JApplicacion but none of his methods allows me to store data.
Not having used Java, but I am pretty sure that the whole PHP platform has no "Application context". You simply need to store them in a database table.
JApplication is used to wrap up all the code that runs as the Joomla CMS. Its livetime nevertheless ends with the end of the request.
HTH, Jochen

Resources