How to use IntelliJ Liveedit with php include - php

I've been working on a webpage and I wanted to break it out into templates that I could pull in. For example the navbar is common to all of the webpages so it gets pulled in like this.
<?php include("templates/navigationBar.html"); ?>
As soon as I move the code out of the index.php into the templates directory IntelliJ LiveEdit plugin stops updating the main index.php (that's including stuff from the templates directory) when I make changes to one of the templates.
I figure this is because the IntelliJ IDE is "stupid" and will only tell the plugin to refresh the page when it exactly matches the page I'm working on. Is there any way to map those notifications from my templates folder into any php file that might include them?
http://confluence.jetbrains.com/display/WI/LiveEdit
http://plugins.jetbrains.com/plugin/?null&pluginId=7007

Related

including wordpress header in whmcs client area

For a project I'm working on I am trying to accomplish to match the whmcs client area to my wordpress site.
So far I've made a lot of progress but I'm stuck right now. I want to include the header of my wordpress site in whmcs.
I tried to implement the static code of my header in the header.tpl file of whmcs. It kind of works but the css conflicts with the main theme of whmcs.
The second thing I tried was to include it with php
<?php include(path/to/header.php'); ?>
Since the header.php is located in the main www directory and whmc is on a subdomain, I was advised to try this:
include($_SERVER['DOCUMENT_ROOT'].'/header.php');
Neither of those two methods worked.
The next thing I did was a new approach. I tried implementing the whmcs layout in wordpress with a plugin called advanced Iframe. It does work but it doesn't always behave as it should and I think it is an better idea to keep whmcs completely on its own subdomain (client.domain.com)
I am no coding genius, so I'm stuck at this point. Are there any workarounds for this?
Assuming the file you're wanting to include the header in is in the same directory as header.php, then you can use
<?php include(__DIR__.'/header.php'); ?>
I have found my mistake.
Since whmcs themes are .tpl, php can't be included directly and is not recommended. What I did was create a new folder in the theme directory with all the assets and a header.tpl file.
Then I included the header.tpl like this.
{include file="$template/header/header.tpl"}
The only downside is that I have to edit the menu manually when changes are made to the WordPress site

CSS not being executed in Woocommerce Wordpress template file

I have a fully functional Wordpress custom theme. I have just installed Woocommerce and followed this guide. I have followed the very basic instructions to copy page.php, rename it and modify the loop. I have done this and am able to use Woocommerce, however in the page.php file, I have a
<?php get_header(); ?>
command, which successfully displays that part of the layout in my normal wordpress pages. However, in the direct clone which is now called woocommerce.php, it is not working fully, The links show up, but without any of the associated css which is linked into the header file. Any ideas why two versions of the same file would mean only one correctly imports / interprets the css?
Here are the two web pages:
http://www.gas-sense.co.uk/blog
http://www.gas-sense.co.uk/blog/product/gas-sense-personal/
OK, I have fixed this now. It was a dreamweaver issue, when cloning the file and renaming it, dreamweaver didn't seem to catch up with updating the links. I have since manually rewritten the references and it is working, thank for your help!

using require in codeigniter

I'm trying to use the uaparser.php library to detect the operating system, but when I use the following it just loads the github page for the library. This is the github page https://github.com/tobie/ua-parser/tree/master/php
<?php
require('uaparser.php');
?>
I've placed the file in my includes folder which resides in the Views directory. Perhaps, that is the source of the problem? Where would be an appropriate place to put this file?
I assume when you downloaded uaparser.php you clicked File->Save Page As... (or something simular). That is why the page loads when you require/include it.
Open up the local file uaparser.php and confirm that it is actually the php code and not the html of the page.
Doing this is fine anywhere you need it.
You can place this anywhere, but for codeigniter it should be in the 3rd party folder, but it doesn't matter.

php class autoload - seems to be caching?

I've recently implemented the following code to autoload classes in my php code:
function my_autoloader($class) {
include 'classes/class_' . $class . '.php';
}
spl_autoload_register('my_autoloader');
The code is contained in file that gets included at the top of all files that need to generate a web page. So then I set about removing the require_once calls from my code. Here's an example:
require_once('classes/class_web_page.php');
As you'll probably gather from the above, the various pages on my site (it's an online community so there's a forum, gallery, etc) all use the web_page class to generate page headings, menus, etc. The various pieces of code create a web_page object, set various parameters to determine what menu options etc are needed, give the page some content, and generate the html.
All seemed well until I made a change to the class_web_page.php file. The change was immediately apparent on most of the site... except for the home page.
I refreshed my browser, switched if off an on again :-) tried calling http://www.terragenesis.co.uk/index.php rather than just http://www.terragenesis.co.uk/, and even stopped and restarted apache on the server. Despite all this the changes didn't show on the home page. In the end I put the require_once line back into index.php... and presto hey: the changes I'd made in class_web_page.php appeared on the home page.
So it looks to me like the autoloader was loading a cached copy of class_web_page.php and nothing, not even restarting Apache, was going to persuade it to get the new version. Why it should do this for the home page and not the other pages... I have no idea.
Has anybody else experienced this? Have I done something wrong with the autoloader code? How can I fix it... or am I going to have to put all the require_once statements back in place? :-(
My server has PHP version 5.1.6
I found the answer to this... and as usual with "bugs" that elude me for days, it turns out that I did something incredibly stupid:
It turns out that at some point in the past I accidentally uploaded a copy of class_web_page.php into the site home directory rather than the classes subdirectory. So it existed twice.
So, it would appear that despite my autoloader telling php to look in the classes subdirectory, it will look first in the same directory as the main script (index.php in the case of my site's home page). All of the other site page scripts are in subdirectories (forum, gallery, etc) so they were "correctly" using the /classes/class_web_page.php
I've now deleted the copy of class_web_page.php that was living in the home directory... and everything works as it should.
Are you sure that this file is actually loaded (or a cached version of it)?

Interspire Template

In Interspire I copy a template & paste it then rename it & I customize it according to my theme but when i go into admin & in admin when i click on design mode then there should be site open for making changes but in my new template it is not open in proper way & I am not be able make changes in this mode please tell me why it is happening in my new template only. in standard template it is working properly. Please tell me the region why this is happening when i select my own template in design mode then there is an error in error-console error is :--- undefined xt/javascript">
After you paste the template, make sure the file is readable by the web server. Insufficient right is the main reason you are not able to modify it.
I'm not 100% sure what you mean about the copy and paste. But the best way to create an Interspire theme is to use the default folder or one of the other ready made templates and do the following:.
Let's say you decide to use the "default" theme. Copy the entire folder somewhere on your computer and rename the folder to the name you'd like your theme to have.
If you are changing specific files, copy those files from _master to the correct directories in your new theme folder.
Upload to your server and activate.
Your theme file names have to remain the same. i.e. you can't rename the files themselves, only the top level theme folder they are in.
Then you can open up the files and make your changes inside of them.
Even though it's possible. I stopped using the built in theme editor once we took the step to create our own theme. For one, doing so kept removing our custom panels when we hit the "save" button.

Categories