How can I put CakePHP templates (CTP files) into HTML? - php

Whilst I am familiar with HTML, CSS, SQL and some Javascript, I know nothing about PHP and my hours of searching on the Internet just takes me to tutorials which show me how to build PHP scripts from scratch, which is not helping me. I am not sure I entirely understand the concepts I am dealing with but I will try and explain as best I can.
I have been given a local copy of a database (developed by somebody else who for logistical reasons I cannot contact at the moment) in MySQL, on an Apache Tomcat server and utilising PHP which was developed in CakePHP and so has several templates from CakePHP. These are all running through Wampserver. The database 'BuddyMe' contains 3 tables - User, Roles and Business Units - and there are corresponding Views using the templates from CakePHP for displaying, editing, and adding entries in these 3 tables.
What I have - a series of files in the WWW directory of Wampserver for these views. These views are in CakePHP 'templates' (CTP files).
What I am trying to do - I have a series of HTML files which at the moment are totally separate from the CTP files. How can I incorporate the Views from the CakePHP templates into my HTML files? I've tried including the CTP files within an IFrame, but I get nothing. There are so many files in the Views that I cannot understand which bits of code I need to lift, or how I can otherwise access the Views from within my own HTML files.
I have gone round and round in circles trying to work this out, any help just to get me going in the right direction would be enormously helpful.

Related

Creating a dynamic download page based on directory

I'm cobbling together a simple website in Bootstrap 3 to serve files on an isolated LAN, I'm not a web developer by trade so apologies if this is a bit of a stupid question:
Is there an easy way to have a webpage dynamically populate with files from a given directory?
For instance, if I just dumped a load of files in /var/www/downloads/, could I have them appear as links in a <ul> on a page?
I know something like this could be written in PHP or I could get people to connect to an FTP service, just wondering if such a solution already exists.

Yii2 How to reference the public main.php file on the server

I used yii2 framework to do three sites, the three sites belonging to different servers, their layouts / main.php exactly the same, how to make these three different domain name website share this main.php?For example, a company's community and forums, as well as the official website are exactly the same layout file, which means that the three sites of the header and footer is the
same, according to my current practice, the three sites are writing this layout File and inside the style and pictures, then the problem occurs, if you want to change the footer and the title html, css, js or pictures, there will be three sites together, this is too much trouble. My current idea is to put the main.php file into one of the site's root directory, and then three sites in the frontend / layouts / main.php reference to the main.php inside the code, but how to do pictures and Style, please Experts advise?
You can include remote files using the allow_url_include directive, but this is a really bad idea because of the security risks.
In my opinion the way to go is to build a module with your layout-related files and then update it in the applications, using composer (or any other tool) when you make changes.
You could use a scaffolding like advanced template where different application (eg: backend and frontend) share common code .. Yii 2 Advanced Project Template is a skeleton Yii 2 application best for developing complex Web applications with multiple tiers.
By default the advanced template includes three tiers: front end, back end, and console, each of which is a separate Yii application. front end and back end app share common namespace for models and config and you can extend for place a common layout or other application based on the same guidelines
This template is also designed to work in a team development environment. It supports deploying the application in different environments.
https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/README.md

Serve CSS and JS from outside of public folder in Laravel 5

I understand this sort of breaks the structured point of Laravel, but there is method to my madness. I plan on using a single install of laravel to host several websites that are database driven. At the moment all of the sites share the same layout and I have a system to store some custom CSS in the DB to give each site a different color scheme. I want to change this so they can use completely different views. So site A loads views/theme1/app.blade.php and site B loads views/theme2/app.blade.php.
I have implemented this by using the following to return a view.
$theme = getDomainThemeName();
return view($theme.'/home');
This is also working, but i am now left with the task of dynamically loading the assets. I am using bootstrap the generate the themes and making a few tweaks to the HTML to create the app.blade.php file. I have 2 potential solutions to this but i would much rather a way to server the css files from the views directory. This means the following mapping.
http://website.com/css/style.css =>
/resources/views/theme1/css/style.css
Can something like this be done? Another option would be to use php to read the css file and insert it into the app using a yield. It works, but it means i cant use browser caching to cache the assets. I was also thinking i could just create sub directories in the public folder. public/theme1/css/style.css. This makes the most logical sense, but it means i have to fragment the theme system. Id like to be able to unzip a theme in the views directory and it just works.
I am using Laravel 5, i have root access to the server too. Running PHP 5.4 on centos 7.
I think the best approach is having next structure:
/public/css/style.css
/public/css/theme1/custom1.css
/resources/views/common.blade.php
/resources/views/theme1/main.blade.php
And then loading conditionally with php each site theme.
It may not be any trouble with caching.

Using multiple php frameworks on one website

Our main website uses symfony 1, and by the time I started working on the code it seems impossible to upgrade (too much custom code from previous developer). Now we are adding a large addition to what the company offers. Instead of using a really old framework I wanted to use CodeIgniter, also since I'm very familiar with it. My real question:
What is a proper way of setting up a website to use multiple frameworks. The new features will be separate from the original website, but it will still need a few tables of the database.
I was going to have apache handle where the root directory was depending on the url and just do everything normally. The main website is example.com and the new feature will be abc.example.com
I'm really looking for people who have done this and some tips and warning they had.
PHP will run the framework based on which directory is loaded on the server. For instance, on most apache servers the root directory for example.com would be /www. Which means all of the code for Symphony would be in /www/*.
When you setup the path of your subdomain, just put it outside of the /www folder. Then, when you go to abc.example.com apache won't try to load the original site along with the Symphony framework.
I think it will be fine for both frameworks to share the same database tables. I'm not entirely sure how you plan for these two applications to work, but as long as you don't change the column names and types you should be okay.
If you don't want the applications to share the data in the original table, then look into using mysqldump or something of the like to copy the data over to a new table.

Using the same php sofware for multiple domains inside the same apache webserver?

Basically, lets say i have a webserver and i resell hosting specifically for local churches.
i have 5 churches as clients, i have a simple CMS made for them they are equal copies of the same files, for each website i install the CMS , database and the website, i think it's a waste of resources.
i would like to know if i can do the following, afaik most webhosts have the following structure:
A main directory (home)
www.church1.com (church1)
www.church2.com (church2)
www.church3.com (church3)
www.church4.com (church4)
www.church5.com (church5)
basically i want the CMS to be on the Home directory, and each one of the Churches (clients) would only have a Config file, a Database ant the template regarding their websites.
so the system source code would be shared, but the website design and the database files would be completelly separated.
i'm not a webhosting or a development expert, but i know my way around, i'm sorry if the question is too basic, i'm having a hard time finding if this is possible.
EDIT: I Think Rudu's reference pretty much solved my problem!
Since you are building it yourself, put the include files (application logic) in a folder or include path that is accessible to all the domains. Then you can put your template files, images and stylesheets in the individual domain folders. If you are database driven you can check the domain $_SERVER['HTTP_HOST'] and load results from a certain table or database based off of that. You really can go a lot of different directions here if you are building it yourself.
It is possible - the answer. Exactly - there are some settings ( and now i dont remember them ) that can block it - but set up in all sites that libraries are there and be happy

Categories