I have these two file in my project that I am migrating from php. I have developed most of it by seeing the functionality but there are these two files which I don't know about. If somebody could have a look and help me converting these, I would really be thankful.
Menu.ctp
<?php
Configure::write('debug', 0);
echo($_GET['callback'].'(');
echo ($javascript->object($profiles));
echo(');');
?>
Retrieve.ctp
<?php
Configure::write('debug', 0);
echo($_GET['callback'].'(');
echo ($javascript->object($profile));
echo(');');
?>
Configure::write('debug', 0);
This tell application to put debug mode to off. If you in debug mode, any application error message will be displayed which is not appropiate for production or ajax call.
echo($_GET['callback'].'(');
$_GET is a global variable which hold all GET request parameter. For example, request to index.php?callback=some_callback will set $_GET['callback'] to some_callback.
echo ($javascript->object($profiles));
This is javascript helper in CakePHP which turn PHP array($profiles) into JSON.
echo($_GET['callback'].'(');
echo ($javascript->object($profile));
echo(');');
This will otuput : callback_parameter(JSON form of profiles);
Related
What is difference between these WordPress functions, and how to implement it?
the_post_navigation(); get_the_post_navigation();
the_archive_title(); get_the_archive_title();
the_post_pagination(); get_the_post_navigation();
the_archive_description(); get_the_archive_description();
I already googled for this, but I'm still not getting it right.
All the functions that starts with get_ are only returning the "result" of the function : If you put this function in a php page and watch this page in a browser, nothing will be displayed.
If you want the result to be displayed, you have to add echo before the function and this is exactly what the function that starts with the_ are doing.
You may ask yourself why sometimes we want only the result to be returned by the function and not displayed. It's because sometime, we have to do some additional operations with the result before displaying it.
Example:
$content = get_the_content();
$content = str_replace('Hello', 'Bye', $content);
echo $content;
If not operation are needed so you only need to do:
the_content();
You also ask "How to implemenent it ?". To implement the function, you will have to add it in some specific php files. For example, for the get_the_post_navigation() function you will have to add it in the single.php file in your theme folder. You will need basics on php.
I'm using the unyson Framework for WordPress and currently using page options which work just fine on that particular page.
But I want to be able to access those options when on another page.
Here is my php -
$page = fw()->theme->get_options( 'service-settings' );
<?php echo wp_kses_post($page['service']['options']['service-box']['options']['description']; ?>
But this doesn't allow me the content from the array.
Using the following I can see the array, but cannot get the data.
fw_print($page);
Thanks guys
You're receiving just options array by calling fw()->theme->get_options('slug') - literally what you typed in the framework-customizations/theme/options/slug.php file.
If you want to receive the actual data you need to use DB helpers.
$data = fw_get_db_settings_option();
// or even refer to individual options, for performance's sake
$individual_option = fw_get_db_settings_option('option_id');
fw_print($data);
fw_print($individual_option);
I am trying to get data (data) from the following URL.
http://www.example.dk/page/?data=1
I use the following code for getting the data to the wordpress page:
<?php $_GET['data']; ?>
But I don't get the data to the page. Isn't it the normal way to get data from URL with php?
As Matt pointed out, you'll need to echo the the result. Like:
<?php echo $_GET['data']; ?>
If your server is setup to use PHP shorthand statements you might also be able to use
<?= $_GET['data'] ?>
In Wordpress, how to make a API like Module, which can accept the data being passed via POST arguments. I mean, the Wordpress should be able to accept the URL calls from external, and then process it.
I mean, as the external Application or myself manually, when i call:
http://www.wordpress-site.com/test?name=james&age=14
Then how to write a module to read such incoming POST values and process it (Save them into the Database or something)
It is actually a public API.
Try with this one:
In Base page it should seems something like this :
Click Here
In Destination page it should seems something like this :
<?php if(isset($_GET['name']) && isset($_GET['age'])){
echo "name=".$_GET['name'];
echo "age=".$_GET['age'];
}
?>
Thanks.
Take a look on WordPress | Accept incoming url with variable parameters
that helps you to get the incoming parameters and wp action hook might be helpful that you want to achieve.
wp action hook
I'm trying to connect to and import data into a WordPress 3.5.1 page template from an external database which is hosted on the same localhost server.
I've Googled this extensively and have come up with the most preferred solution for this:
<?php
/*
Template Name: Import Sign data
*/
?>
<?php echo "Import Sign Data Page<br>"; ?>
<?php
$mydb = new wpdb('myname', 'mypassword', 'mydb', 'localhost');
$mydb->show_errors();
$signs = $mydb->get_results("SELECT * FROM signs");
print_r($signs);
foreach ($signs as $sign) {
echo $sign->title . '<br />';
}
?>
The code above only gives me the first echo, 'Import Sign Data Page' and nothing else. No errors, nothing. I've checked all my syntax many times now. Can any see where I might have gone wrong here or perhaps suggest some debugging tips?
TIA
Using the wpdb class is by definition only going to work with the installed wordpress database. You should use whatever functions that pertain to your external database.