run a function on each page - php

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.

Related

How to use php pages in Joomla?

I have 2 php pages, form.php and results.php. The form accepts user data and send to the database with mysql query, the results page retrieves the data for display.
I have installed Joomla as my CMS and it is connected with the database in which the form data is also stored.
How can i use these two pages in joomla?
You are better off developing a component for Joomla as that is the correct way to extend the functionality. Take a look at http://www.component-creator.com it can write all the code for you.
You can place these two pages into your web root directory & those will work.
If you want to use configurations defined for Joomla, just include those files into your PHP files.
If you want to place your form within a Joomla article, I would suggest using a form builder extension - there are quite a few in the Joomla extensions directory: http://extensions.joomla.org/extensions/contacts-and-feedback/forms
Using an extension like this will allow you to create your form in the Joomla admin area, publish it to your site, and then accept submissions which could then be emailed to you or viewed in the admin area.

Codeigniter Website is not responding

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');

Assign template joomla with sessions

I need to change the template depends on the sessions, that means Once user logged in we need to change the template.
note: I need to achieve this by coding not from administrator.
any help?
Have you tried googling the subject?
Using "Joomla Pluggin User Template" i get a post regarding a pluggin provided by rockettheme that gives a dropdown list savable...
Maybe try to search next time?
http://www.google.ca/search?q=joomla+pluggin+template+per+user&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:fr:official&client=firefox-a
I have solved my problem with assigning template manually through coding part.
I did by changing the function in includes/application.php
Function name is getTemplate(); This function returns the template name.
Its worked for me.
i don't think so that it is possible, cause Joomla is a CMS(Content Management System)
and it has its own rule to develop your site.
If you want that kind of feature then you have to leave to use CMS and have to develop dynamic website
EDIT according to #jprofitt, it is possible with some CSS tricks, just detect the login session of the user and apply that CSS but i think, for this you have to detect the session on the index.php file, that is your template file, i am not sure cause i never did that.

Inline Editing (mojomotor like) for Code Igniter project?

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

Wordpress: using a test theme only for a specific user

I'm testing a new template for a wordpress based site, and I'd like to test it directly on the live version instead of making copies. I thought I could create a test user (wordpress is bridged with vbulletin which handles user auth), serve the usual theme to anyone BUT that specific user, who would get the new testing one.
I don't want to install a plugin, I'm looking for the right place to edit to insert this check:
if logged user == test_user_id
serve 'testtheme'
else
serve 'normaltheme'
The userid can be get from $_COOKIE.
I tried hacking the get_template() function in wp-include/theme.php but apparently that was not enough. Any suggestion?
This is the best way to "test" or develop a theme behind the scenes without needing to alter too much of your Wordpress core or make custom changes...
http://digwp.com/2009/12/develop-themes-behind-the-scenes/
Just logging into my old Wordpress.com blog, I see that I can do all the previewing I want from the themes manager already - click around to any page I like, or bring up the frame's URL to see what query string I'd have to append to a URL to get the same preview, e.g.
?preview=1&template=pub/mytheme&stylesheet=pub/mytheme
Any reason that's not enough?
Perhaps you should add a column to your user table, call it "is_beta" and if it's set to 1 then enable beta features/themes. This way you can easily add or remove people from the beta, and when you're beta is ready to launch, you flush the column for everybody and make the features default.

Categories