I have been trying to get more information regarding this, but was not able to find something yet.
We have Competition Admin Back-ends for multiple Competition Organizers, each within their own CodeInginter folder.
All of these projects have a load of files that they share with the exact content. I was wondering if there is a way of storing these views somewhere on an external domain/folder outside of their CodeIgniter folder, so that I would only need to update and upload one single file instead of doing so for each project.
I do believe that this will be a security risk, so I am not sure if it is even possible, but would make my life a lot easier.
The only way that I could find to do something similar was to use PHP's file_get_contents and echo that to act like the view file
echo file_get_contents("http://myurl.com/statement");
But with this I would have to create a central project to handle these "shared" functions, and not just store the view somewhere.
I guess that this will still work, but was wondering if there could have been another way to do so.
Hope that somebody can shed some light on this.
Thanx in advance
Related
I didn't have much experiences about the CMS (like wordpess, joomla or movabletype) so I don't know my task is possible or NOT.
My customer, they buy and use the CMS (MovableTypes) to make their website. So now they want me to find or write (Code) the new function for website. That function will be get and show the related blogs (entries) like for example:
"if you go to ebay and click to view a cellphone, the website will give you recommend cellphone which have same properties of the current."
In PHP, I can know how to do this, but in MovableTypes I don't know, have anyone had some experience about the MovableType.
They have documentation for extension development here:
https://movabletype.org/documentation/developer/
Whilst following their framework is usually sensible and worth taking the time to do, most CMSs will also usually allow you to find a place to just write in raw PHP via a very basic extension.
Just make sure you never edit core files.
I am trying to make my first sitemap to use with google for the site that I am making. The thing is that all the displayed content is static, all the solutions i found are related with the usage of models. How can I make a sitemap for a Cake site like this? Also, is it possible to do it using the Routes, on routes.php file or does it need to be made in a more complex way?
I am using CakePHP 2.4.4.
In case you don't need any dynamic content (from the way you asked your question there is no way of knowing if you do), just create a static
sitemap.xml
in your /webroot directly
That's it.
Nothing else necessary.
Always keep things as simple as possible.
For the most part, the 3 sites for an organization I run have a single MySQL database that they share. This allows them to interact with each other nicely.
I have a bunch of simple parameters that the sites need to know about, and I wasn't sure what the best route to take is:
Make a table with 2 fields (key, value) where I store the params
Store the values in one or many flat files
They each have advantages and disadvantages.
The database allows a single entry to be used for all three sites (however, this doesn't occur often), all the information is centralized, and the interface is already well defined.
The flat files are easier to work with as FTP and a text editor can be used in addition to website administration, the flat files can be written as PHP meaning the site doesn't have to do any parsing (just need to include the file and use the variables), but they can't be shared between sites.
I can go on and on. What do you think is the better route to take?
My opinion is to use a database if you have the chance. It's easier on the long run. You have built the website, with the flat files, but now the customer wants an additional page with slightly other parameters, so you have to add a new file. Now you are done with this and he ask you again.. well, you get the point.
It is not organised at all. So if you have the chance to use a database, use it. There is reason why it is invented.
But just to get my thoughts clear and firmly know what you are talking about, please tell me more about the settings you would like to store. I can imagine that you are talking about some global variables, or maybe even going to use a define(), but it is also possible you want to store strings.
So please define "bunch of simple parameters" for us.
I was wondering if there is a way to make the following process more automated (so links automatically update throughout if the links get changed).
I have a PHP site, with a front controller.
Now I'm wondering how would I go about displaying certain links (to pages) within the different PHP files? (I don't want to actually do so manually...as that would mean if the page name got changed I'd have to manually flick through all the files).
Basically what I'm looking for is a way I can include links to pages on my site easily and automatically.
I had an idea of storing them in an config array and then using some sort of wrapper/helper function in the PHP files to retrieve them from the config array and display them (but not sure if its the best way forward or if there are other ways)?
Perhaps something like how WordPress does it (although I'm not familiar with it I've heard that its using a similar technique...) as what I have is a front controller alongside a mapping array (containing the urls of the pages) - if that helps.
Appreciate all approaches and responses.
I recommend looking at some of PHP's great MVC frameworks for the best examples of using the strengths of MVC to do dynamic routing and access those routes in your views, so they update automatically.
Code Igniter, CakePHP, Zend Framework
I'm partial to CodeIgniter myself, but they all have their strengths.
I seriously suggest you look into adopting one of these frameworks if your application is complex enough to need this level of route management. No need to reinvent the wheel. Using a framework lets you spend less time messing with the nuts and bolts and more time just building your application.
Whether you use the framework or not, they are probably better examples of good object oriented design than you are likely to find in wordpress.
I'm building an IMDB.com like website using PHP/jQuery and a MVC approach (no OOP).
I have an index.php base controller to 'rule them all' :), a controllers folder with all the controllers, a models folder and a view folder.
In some pages of the website I have tabbed navigation, when the visitor clicks on one of those tabs to get more information, jQuery gets that data using the $.post or $.get method and shows it on the tab container, obviously without refreshing the page.
The problem is that those pages loaded by ajax are also generated using controllers, models, and views, and the things are getting a bit complicated for someone like me ( = 'no experience'). To dynamically get the data I some times need to include a model twice, include an include in an include in an include, send information multiple times, connect with the database again, and all sort of things like that and I'm sure there is a better and prettier way to do this.
I'm searching for the best approach and common methods for this. I have no experience working with a big project like this. This is a personal project so I have full control and every answer is welcome.
Thanks!!!
You can check the X-Requested-With header that most js frameworks send to see if the request is coming via ajax. Then you can only output certain data and not the "entire page".
Not sure why you need multiple includes like you say, maybe you need to rework your logic.
Post some code and we can be of better help.
"To dynamically get the data I some times need to include a model twice, include an include in an include in an include, send information multiple times, connect with the database again, and all sort of things like that and I'm sure there is a better and prettier way to do this."
I think you need a better 'design' for you MVC application. Multiple includes - i am guessing in the different layers of the MVC framework might be indicators that your design needs more attention.
I'll try and be short:
Other frameworks i.e. handle requests via XMLHTTPRequest by AMONG others, disabling or enabling the VIEW or LAYOUT explicitly - check Zend Framework - (e.g. you need to send a JSON encoded string as a response). These requests are handled just as any other request.
I would suggest you have a look at other popular frameworks. Check the application design and layout, and pay attention on the Routing and Dispatching of Actions. I suggest you follow this path since as you say you lack experience.
good luck with your project.