I've just started using Slim and Twig and getting to grips with it all.
I am building a small site and will have a Twitter feed on every page. So, I want to put this in my layout template (base.html.twig). The only way I can see to do it is to pass it in to every route and then use an include that can access the details.
Seems like there must be a way to set it in the layout template once without passing it in through every route?
Any help or a related link would be great.
you can extend twig with user defined functions, just make a call inside template and you will not need for passing it every time http://twig.sensiolabs.org/doc/advanced.html#creating-an-extension
Related
I've create a custom Store route inside Shopware 6 as a plugin.
It shows up in the store-api/_info/swagger.html url.
What is does is it return an array with static text for now.
Now is my question, how would i call this url inside the pwa with vuestorefront.
I created a page inside src/pages but i cant wrap my mind around how to call the url to ge the data.
Do i need to specify the whole url in the axios? I cant find any documentation about this.
Thanks in advance!
You approach so far is correct.
Create a new Store API route to fetch data from Shopware
Create a new Nuxt page by creating a page in src/pages.
Now we only need to connect the dots.
Nuxt pages are simply Vue components, so you can use the invokePost or invokeGet methods from the shopware-6-client package to call your custom endpoint.
You could also use axios to do it, but then you'll need to handle additional parameters (e.g. passing the correct sw-context-token or sw-access-key manually.
My question is how to make a hyperlink in a view? Like in HTML. Have I to create it in an action method in the controller and then send it to a view? or what exactly?
If you are using the Twig templating engine you would have something like
Home
If you are using PHP for your templates you would have something like
Home
homepage in the above examples is a route identifier that you must already have defined in your routing configuration
Define the anchor text in the view.
Views are exactly what they sound like they're for, providing view to the visitor. Controllers, models are all for the internal processing & logic of the application.
I'm developing a very small cms kind of thing. So far I have a page controller that lets you add pages. And there is a frontend controller. All calls are received by the frontend controller and respective page is displayed. Now I want to allow some custom tags while creating a page. I am using CKEditor and I want that while creating a page user gives a tag like <!--cmsform_printform--> and this tag will print printform method of cmsform controller.
For this I have created a controller cmsform that has a method printform. In my fronend controller I have created a method replace_tags that searches tags and then call respective controller and method.
But now I realized that my logic was false because I should not load a controller in another controller. I can't think of anyother logic. Please someone guide me or redirect me to a good codeigniter tutorial that explains this.
Thanks
Have you tried writing a helper instead? The functionality you describe sounds more like a helper method than a controller action.
CI manual in their site lists several excellent video tutorials, notably the ones published on NetTuts+. You might want to have a look, if you haven't already. Also, please do search CI forums. They contain plenty of information on pretty much any CI-related topic.
I'm trying to create a page that displays certain widgets/includes dependent on the users permissions. I'm quite new to CodeIgniter and MVC.
Example.
I have a calendar. This has a controller, model and view and it needs to be included on other pages.
I want this calendar and a number of other similar 'widgets' to be displayed on one page. This page currently has a controller and view.
I know I shouldn't be loading a controller from another controller, but can't see a way round it.
Can you load multiple controllers from a helper, or do I need some form of template?
Thanks,
Jacqui
It sounds to me like you are looking for Modular Extensions for CodeIgniter. This allows you to break an application into modules that can be called from one another. In your case, you would have a calendar module which you could call from your other modules.
What you might be looking for is something called Layouts. Codeigniter does not have such a feature out of the box but layouts are basically delegating a (front-controller) request across multiple actions. Each action works on it's own and has it's own view assigned.
The layout will take care to put this all together into one output then.
This methodology takes care as well that you don't call one controller from another controller so you keep code apart that does not belong to each other or would get messed up because it does too much at once.
This discussion might be interesting for you: Codeigniter layouts?, the Codeigniter FAQ has more about it as well and more specifically Header and footer and menu on every page in the wiki.
I want to execute some code right before the layout is rendered, after all other code is executed. Where would I put that code?
I am specifically trying to modify the files referenced in the headLink, headScript, and inlineScript view helpers before they're used by the layout.
Here are the steps I want to take:
Loop over the files in those view helpers
Make a list of the local files
Remove local files from the view helpers
Reference the local file list as a parameter to a server script that combines them for a single HTTP request
Add that new combine script reference to the appropriate view helper
It doesn't appear that a Front Controller Plugin is going to help me accomplish this, and here's why:
postDispatch() gets executed after every controller action that's executed, and I need the full list of stylesheets/javascripts
dispatchLoopShutdown() gets executed after the controller action loop, but the layout has already been rendered at this point
As Rufinus suggested, I solved this by extending the View Helpers. My question from that angle as well as the solution is here.
see Orginal PDF created by Thorsten Ruf
(Mirror)
the very last part you can access via plugin should be dispatchLoopShutdown
EDIT:
For ZendFramework2 see http://zendframework2.de/en/cheat-sheet.html
or this gdoc