I am using the codeigniter framework for my website.
Previously my website was working fine. But a few days ago I made some changes in code (I add some files for cron job).
When I made these changes my website is not responding it is continuously connecting to the server.
I am using the stencil with the codeigniter.
When I use the ordinary codeigniter view function:
$this->load->view('view_name');
It was working but as I am using stencil paint:
$this->stencil->paint('view_name'); // its not working.
Website URL: http://blogsetu.com/
I would recommend you to read the documentation again there is something you might have missed we can't say any thing without viewing the full source code
However I think you missed to set a layout
from http://scotch.io/docs/stencil
Bare Minimum to Get Started Set a Layout in your Controller
You always will need to set a layout. This is required for Stencil.
Layouts are located in "/views/layouts/". To learn more, visit the
docs about layouts.
$this->stencil->layout('default_layout'); Set and Load a View with
the "paint()" function
To set and load a view you will initiate the "paint()" function. This
function is the equivalent to "$this->load->view($view)" in
Codeigniter.
To learn how to bind data to the view, please click here.
These are located in the "Pages" folder inside of the views folder.
The HTML from these pages are made available in the layout as the
$content variable.
$this->stencil->paint('example_view');
Related
I have a client with a Drupal 8 running site. They want to one URL of the site to render very different from the rest of the site. I have created a module. I need just a single route to override html.html.twig. I want to strip out the majority of the stuff the site theme is loading. I am sort of able to get it to work but it seems to apply to every page which effectively breaks the site. This url /site/mynewapp would use completely different layout and html from the rest of the hundreds of other pages. Basically this is a static site within an existing Drupal 8 instance. How do I conditionally load a custom html.html.twig, page.html.twig, and node.html.twig only when /site/mynewapp is requested? This is a ReactJS app basically that should only run on a single page of the site. I realize this isn't the ideal architecture. I have asked the client to run the app separately on nodejs but they insist it must be within their existing Drupal instance. The React app looks nothing like the rest of site. Does anyone have experience doing something like this. I have custommodule.routing.yml with the route defined and a controller method that bolts on the javascript lib. This works but it seems to load on every page which can't happen.
public function overview()
{
$build = [];
$build['#attached']['library'][] = 'mymodule/mylibrary';
$build['#markup'] = '<div id="root"></div>';
return $build;
}
and in the module file
function mymodule_theme_registry_alter(&$theme_registry)
{
$theme_registry['html']['path'] = drupal_get_path('module',
'mymodule') . '/templates';
}
this is loads the html.html.twig for every page in the site essentially breaking it.
Any suggestions here?
You don't need a module to override the twig template.
You just create the files in your theme folder with the right name and you are ready to go.
To override html.html.twig you have to create something like html--mynewapp.html.twig
To override page.html.twig you have to create something like page--mynewapp.html.twig
To override node.html.twig you have to create something like node--mynewapp.html.twig
You clear the cache and the new template will load when you visit these pages.
The react mount node module will embed an empty div to mount your React page within your Drupal site in the content region.
If you truly want a completely separate React app inside of Drupal, you can just build it in a subfolder of your site. Like /myapp and put the whole build in there.
Hi all im working on zf2, I was allways including js files from the view pages. But i can include it in the controller also using appendscript(). Which is the best method according to mvc ?
Javascript works with view output - the view knows, what javascript is needed to make everything work. And the view might not be directed to the browser, other view media might be used. For this reason, I prefere adding javascript from inside view.
My codeigniter app is multilingual and I want to redirect users to their pages, by checking IP address.
I should check it at the top of all pages (i know i can set a session or cookie, but i want to check it on all pages); before any views or other.
Where should i put my code (function)? on Startup file or Loader? or create an extension or plugin and load it on Startup? if it can be done by an extension or plugin, how can I create it? (i've searched, but didn't find a useful tutorial)
Thanks.
If you're using a main front controller you can put your code in there. But a better way to do it would be to use CodeIgniters built in functionality to extend the core - hooks!
http://codeigniter.com/user_guide/general/hooks.html
Just select the point you want your script to be activated and take it from there.
I recently purchased a script that I'm trying to change the CSS to pimp it up :)
However since I'm fairly new to CSS/PHP (I've done ASP before), I'm trying to use the "Live view" feature Dreamweaver 5.5 to edit the tpl.php files. I have setup the site as instructed in DW and it's working with basic PHP files, however when I try to open a tpl.php file it doesnt seem to handle all the includes or something, so essentially it doesnt know how to retrieve all the related CSS etc in order to show me what the site looks like.
It has the following code structure:
www.xyz.com -> this calls the index.php
Within index.php, it calls include_once ('global_mainpage.php');
Within global_mainpage.php it then calls $template_output .= $template->process('mainpage.tpl.php');
mainpage.tpl.php is the file that I need to change the layouts/CSS class reference etc.
My ideal way to work with the site is:
Say if I want to change something on index.php
I just click on one of the elements in live view
It would automatically launch the tpl.php file being used
I can then examine the CSS used and make a change to it
hit save and be able to view the change I just made
If this is not possible, do I have no choice but to use Aptana? I've used it before editing PHP code, but not tpl.php - I was hoping to have a WYSIWYG editor for tpl.php...
Many thanks for your help gurus! :)
Why don't you use FireBug on Firefox and hook it up with cssUpdater?
So I've built my site in Code Igniter and there are a number of pages where I feel it'd be easiest if the client could edit the content inline - much like what MojoMotor offers.
I'm not interested in using mojomotor but I wondered if anyone had done anything like this for their code igniter project?
As an idea of how it could work:
I was thinking that the client admin user could login to the normal custom built admin CMS area. After logged in, with session set, they can browse out to the public site for selected pages.
These pages will have a check for that admin session built in and if it's present, it can include a js file, which will overlay an admin banner and somehow enable the fields (perhaps content divs with a certain id or class relating to the corresponding table/field in DB) for editing.
--EDIT--
I've seen quite a few js inline editors around. I guess my confusion is over how best to integrate them with my database and controllers - i.e. idea of having the div id/class somehow map to the db field.
The bottom line is that MojoMotor is a CodeIgniter app and not a library. Therefore trying to work the code into your existing CodeIgniter project is not really an option.
But if you're willing, you can integrate your CodeIgniter project into MojoMotor and have the benefits of both. Here is a series of articles written on how to do this.
This is one example of the code you are looking for . You'll have to adapt the method for use with CI