If I have a view located at application/views/templates/games/gamename/ is there a way to turn off mod_rewrite for that directory?
Also, is there a way to not use the smarty templating for that view?
The reason I want to do this is because I have a java script game which unfortunately is having trouble getting data from the backend, therefore the game fails to load and gets stuck on the preloader. This is also why I want to turn off the smarty template because it is not properly loading the correct assets.
I think you're focusing yourself in the wrong way to solve the problem. If you're having trouble with your request from the frontend to the backend, then, change the call in the JS to point out the right file, or route the call correctly in application/config/routes.php
Related
I have a widget that I want to plug into my angular view. I'm not sure I'm explaining it right but the code I get from the site that makes/hosts the widget is below:
<script src="http://www.somesite.com/widgetfile.js"></script>
This works perfectly fine on a standard html site (just a simple html file loaded locally in my browser). It loads the external JS file and does a document.write onto my DOM as far as I can tell.
The problem I'm having is putting this on a view in an Angular app I've built. I thought it would be the same thing as just copy/pasting the single line of script that the site gave me, but it doesn't work... error i get is below (Chrome).
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
I can't use something other than document.write because I don't have access to the file itself, the site that generates the widget does that for me. I've tried doing $http get request in my controller than putting that to a scope variable to be put on the DOM, but I get an error about cross domain security.
Any thoughts? This seems super basic to me since there are thousands of sites that offer "One line of code to embed a widget"... and it works in basic HTML pages. Am I missing something stupid (keep in mind that yes, I did copy and paste the widget script directly from the site that hosts it).
Thanks for the help. I'm pretty new with coding and newer at angular, but this seems like something that should be borderline plug-n-play and not need some complex cross domain workaround.
Try these with these two links.
http://ngmodules.org/modules/angular-widget
https://github.com/cztomsik/ng-widgets
I am developing a WP Plugin.
Currently, I am making an ajax call with jquery to a standalone php file in my plugin folder.
Let's presume that this file is called test.php.
The file is NOT loaded prior to this call, so no native wordpress functions work in this file.
As a result, I have require_once('wp.load'); in test.php.
Here stems my questions:
The only function I need from wordpress is $wpdb->insert. Is there a better function to include than wp-load? Something that doesn't include so much, since all I need is this one function!
I understand that require_once loads the file, ONLY if it hasn't been loaded yet. Maybe I'm overlooking the situation, but how does this work with ajax? If there is a "success" response, does test.php close, thus when its called again, it loads wp-load.php again?
Thanks!
If there is a "success" response, does test.php close, thus when its
called again, it loads wp-load.php again?
Exactly. The concept behind require_once (or include_once) is to make sure you don’t reload the same functions, classes & variables into the same currently running PHP code at the same time:
include_once may be used in cases where the same file might be
included and evaluated more than once during a particular execution of
a script, so in this case it may help avoid problems such as function
redefinitions, variable value reassignments, etc.
And since PHP scripts run only on request, what you describe is exactly how it would happen.
That said, I wouldn’t over-think the concept of loading the whole wp.load each time it’s needed. I doubt it will cause such a performance hit that it would even be noticeable.
You should consider follow this method to write an Ajax powered plugin. There is usualy no need to create a separate PHP file and load WordPress core into that file. Read that carefully and you'll find out, that is relatively easy to accomplish and is more flexible thant stand alone PHP file...
I believe Smarty templates has functionality built in that allows you to manage your site URLs from a config file so if something gets moved, you only have to update the URL in one place. Does this sort of functionality exist in CodeIgniter? If not, any pointers or examples on how/where to add it?
For example:
Instead of hard-coding the link it would be: Settings
But where would you want to set $links so that it was available everywhere? Or is it really best to just hard code them?
Take a look at the config class. It allows you to make custom config files.
It's not entirely made for URL's but you sure can use them.
The base url should be basically right at the start of /app/config/config.php, where app is the name of your codeigniter application folder. You access it through calls to the base_url() function.
Yes, it's called Routes, configuration located at config/routes.php. Documentation
If you ask about the rendered html of the links, then your best bet would be using site_url() in conjunction with constants, for example site_url(URL_SETTINGS);, there is no built in functionality for that, but I can say I don't think that is necessary as it would be used too rarely, but it would influence performance every single load.
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.
I have a C#.Net web app and the pathing is different from my local box to the dev box. My local url is http://localhost:<port>/Proposal/Edit. However, on the dev server, it is http://{MydevServer}/dev/app/Proposal/Edit]. So, this causes issues with the Style Sheet and navigation links, etc. I know I can grab the ApplicationPath inside all the Controllers and set a variable whic the pathed elements can use. But that seems like too much work for this issue. Any ideas on how to solve this? Is it possible to get the ApplicaionPath in the _Layout.cshhml file? Is ther a better idea?
You can call Href("~/") in any Razor page to get the full client path to your application root.
you should be using the Url.Action and Url.Content helper methods for generating your links and src attributes. then you'll never need to worry about it.