Using Wordpress in CakePHP for views - wordpress

I'm using the latest version of Wordpress for the public portion of my site and CakePHP for the actual web application. Since I want to keep the application consistent, I want to use Wordpress functions (for example get_header(), get_sidebar(), and get_footer()) to achieve this in my view files. Can I just use an require statement and call in the functions I need? Has anyone done this? Would there be any conflicts (e.g. functions with the same name) and is there a way to avoid it?
Additionally, I know CakePHP usually assumes path are relative to the app/ directory. Is there a way to get around this?

I recently tried something similar. You would be combining both codebases, and yes, there are name collisions. PHP5 namespaces would fix this, but they are only planned for CakePHP 3.0.

I'm not sure about including certain parts of WordPress into a CakePHP app, it would probably get quite messy and WP might fail if its being loaded in a different path to what it expects. Unless someone else has done it before you might find yourself doing a lot of work and discovering that it can't be done at all.
There are some guides to installing them side-by-side, but nothing seems to cover grabbing posts, and parts of the template from WP in Cake.
Here are the some options I would think about:
1) Having WP located in /blog and simply make sure your WP theme matches your CakePHP layout visually.
2) Build a simple blogging platform into your Cake application.
3) Build the CakePHP part of your application as a WordPress plugin.

Related

Possible to limit which custom modules for a multisite?

I'm using a multisite setup in Drupal 7. I'm wondering if it's possible to limit where a site can look for which modules to use. For example, there are a lot of modules I'd like to be able to use across all sites (../sites/all/modules/). But I would like Site A to have access to modules/custom/siteA, but not modules/custom/siteB.
Is this possible or do I have to share all modules across all sites?
You're thinking of it the wrong way; going depth first instead of breadth first. This is one of the "benefits" to going multisite.
In Drupal 7, you should be able to put any modules you want only to appear to a specific site into it's sites/site-name/modules/ directory; site-name being whatever directory you mapped the sites/sites.php file to go to for the given URL. I think you should already have a settings.php file in your sites/site-name directory. Just add the modules folder and dump them in. I'm not really sure how to handle it further, or how to install site-specific modules from the site GUI (if that's possible.)
I only put benefits in quotes because I've never been a fan of going multisite, but plenty of people have been more than happy to and it's worked out great for them.
this is quite easy. Suppose there are two sites you have created with multisite installation.
Site A (root site)
Site B
The modules that are common will be placed in sites/all/modules directory. But you can define some modules to appear in the site B only by placing the same in
sites/SiteB/modules.
I hope, it is making sense for you. Otherwise feel free to ask your queries.
All the Best!!

Restarting a wordpress project

I am a freelance developer, and I normally build sites from scratch without using any code generating sites like WordPress or Square Space. But my current client insists on using WordPress. However, I am rescuing this project from a previous developer who made a big mess because from the looks of it does not seem like they knew what they were doing.
Is there a way for me to restart everything, on a clean slate and template on WordPress? I would like to have none of what the previous developer has done. Also is there a way for me do do direct coding using HTML, CSS, JavaScript etc on a WordPress site?
Yes, you just need to look into how to create a theme, since themes are the basis of the Wordpress structure. Ultimately, if you have the code for a website, it can be broken into separate files that Wordpress can use.
See: http://www.wpexplorer.com/create-wordpress-theme-html-1/
If the previous developer has done all the work in the theme files, then simply switching the theme to a default theme (Like Twenty Sixteen) will give you a nice clean slate to dig in and jump off with. You will want to create a child theme of any existing theme if you want to make any changes. If, however, the developer has messed with other files besides the theme folder, then you will most likely want to export the content only (as a logged-in administrator, go to Tools > Export (here's a screenshot))
Then on a new environment (I prefer testing these things first on a local virtual environment like VVV, and then transition to a development subdomain on the same server that the site will eventually go live on and securing it with an htaccess user/password to block curious eyes), import the content on a fresh installation of wordpress via the same menu (Tools > Import). This will give you a fresh installation with the content that's been created, but without any of the mess.
For more information about importing content - here's the codex article.
I hope that's a good start - but if I've glossed over anything you don't understand, let me know - I'm happy to help.

drupal_get_private_key equivalent Wordpress

I'm trying to convert the theme from Drupal to Wordpress, I don't know a lot about drupal, so this function "drupal_get_private_key" confuses me a little and I can't really find a lot of documentation about it. Could someone explain me what is this function about and how could I do this in Wordpress?
Thank you for the help
Drupal uses this to generate the paths to files* (its used in other stuff too, but in themming I believe its the main reason).
*These files are the files created by users, not the files in the theme folder. The folders are configured in the admin and, when an user uploads a news picture, for example, it will be placed in the configured folder.
You problably just want to find another way to find these paths.

Static html to wordpress migration

I have a static HTML site (about ten years old) which I am going to migrate to a Wordpress site.
I have used Wordpress before but never as a migration target. From some initial background reading I have come up with the following process to perform the migration:
Check hosting provider/package for Wordpress suitability
Generate complete current site map
Make a complete backup of current site
Install Wordpress in subdirectory
Install Maintenance mode plugin and activate
Migrate content to Wordpress instance (looks like this could be
painstaking..)
Install suitable theme
Customise selected theme with Logo/fonts/colours etc.
Deactivate maintenance mode
Make Wordpress site available from domain root
Delete old static html site files
(The migration may take place over several weeks/months so I need the static HTML site to be available until step 10 is completed)
In my naivety are there any pitfalls in the above process, or additional issues I have failed to consider?
Are there any other accepted 'best practices' when performing this kind of migration?
Here's a good tutorial:
http://code.tutsplus.com/tutorials/creating-a-wordpress-theme-from-static-html-creating-template-files--wp-33939
For developers who want the theme converted from HTML in easy way (but no guarantee if it can produce the output as expected):
http://www.htmltowordpressconverter.com/
Hope this was helpful!!!!
WordPress theme styles come in all shapes and sizes. Converting from a static HTML site to something database driven like WordPress can be as easy or complicated as you want.
If you just want to integrate WordPress into an existing HTML theme it's as easy as installing WP, setup the database and config, then building in the old HTML structure using WP. This way everything will be the same but managed within WordPress i.e. Pages, Menus, Sidebars.
Here's are some useful links:
https://codex.wordpress.org/Using_Themes
https://codex.wordpress.org/Theme_Development
https://codex.wordpress.org/Stepping_Into_Templates
And here's a "Start from Scratch" theme that would be simple to start from. Just install it, activate it, then begin migrating the main content i.e. copy and images etc, and building the theme itself.
http://adopttheweb.com/start-from-scratch.zip

why we are using the ../../../wp-load.php in wordpress?

Sorry for asking this type of stupid ques.
But i don't know I need your help
I look out the coding that they are in wordpress plugin.
require_once('../../../wp-load.php');
I really don't know what the ../../.. is perform some one know ,let me give an suggestion
I am not tell about the core file and all .that extension before the php file.
Thanks.
That loads the WordPress framework for use outside of the native environment.
For example, if you wanted to have a PHP controller that handled AJAX requests, you could load the WordPress environment to validate the current WordPress user login status.
The "../../.." tells the require function to start at the current file, go up three directories, then access wp-load.php.
Based on that path, I can guess that the file is sitting in a theme folder. wp-content/themes/yourtheme

Resources