Is there any way to find page by id in layout file. I'm currently using
$this->fuel->pages->find(5)
But its not working. I'm getting following error message
Plugin module can not be found, maybe you forgot to bind it if it's a
custom plugin ?
You have to use an array to pass parameters in the method and you can use the find_one.
$this->fuel->pages->find_one(array('where' => array('id' => 5)))
Related
We are using wordpress for blogs (hosted via Godaddy). I am not a wordpress developer and hence this basic question. We have the wordpress post api like blog.domainname.com/wp-json/wp/v2/posts. This returns a json object of most of the fields. Now i have added a custom field to be returned with this object. i have seen lot of videos and study on what changes that needs to be done especially the one here.
https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/
My Question is - Where do I make these changes? What file do I need add these changes? I am using WP as an admin. I installed a File Explorer plugin and I am able to see three main folders - wp-admin, wp-content, wp-includes.
Is there a particular file i need to make changes? Based on my learning - i wrote the following snippet. not sure where to add this :(
function addCustomField_register_fields() {
register_rest_field('post',
'custom_Field_name',
array(
'get_callback' =>'get_custom_field',
'update_callback' => null,
'schema' => null
));
}
function get_custom_field($object, $field_name , $request) {
return get_post('custom_field');
}
add_action('rest_api_init', 'addCustomField_register_fields');
Also would appreciate if you can let me know if my method is correct.
Typically theme customisations are added to the functions.php file in the root directory of your active theme.
As for your code, what are you trying to do? Your callback in particular doesn't look like it will work. get_post() loads a WordPress post by ID. 'custom_field' isn't a valid post ID, so this will always fail.
I am trying to create category from WordPress plugin. Here is my code:
$id = wp_create_category('Category_name', 2);
But i am getting this
error:
Missing argument 4 for wp_insert_term(), called in taxonomy.php on line 144 and defined in taxonomy.php on line 2226
But i am not using function wp_insert_term() anywhere. Please help me. What i am doing wrong? is there anything extra which i have to do in plugin to make it working?
Thanks in advance
try to use wp_insert_category as wp_create_category is just a wrapper for it.
Passing a category ID means you're trying to create a child category, so make sure that a category with and ID of 2 exists.
If you do have a category with an ID of 2, try omitting that param and seeing what happens. If your still getting an error after that, check what version of PHP you are using and update it.
If you're making a plugin to add a category to the database you will be better off using wp_insert_category() as it gives you more control.
I have read all the related questions in SO and Opencart Forum but couldn't find solution.
So I have copy featured module and edited some of code, not too much and Now i want to show this new module direct in front on only success page. So i have put this code in catalog/controller/checkout/success.php
$data['successpage'] = $this->load->controller('module/successpage');
and in ***catalog/view/theme/default/template/common/success.tpl
<?php echo $successpage; ?>
Now i getting
error Undefined index: limit in controller\module\successpage.php on line 20
* I think its b'coz some variables values need to send in module controller file
And i have try all the answer for this but can't get solution.
Thanks If you know and help me to sort out.
You might get an error as there is not any settings (data) is passed in index method of your class ControllerModuleSuccesspage. You are directly calling $data['successpage'] = $this->load->controller('module/successpage');
Try to display your successpage module by setting from admin side. (From layout). If you want to call it directly then first check for condition if ($setting['any index']) { ..... } else {... }.
If you want to pass any parameter without setting up from admin side than do this.
$parameters = array(
'name' => 'Your module name',
'product' => array(43,40,42,30), // product id
'limit' => 4,
'width' => 200 ,
'height' => 200,
'status' => 1
);
$data['successpage'] = $this->load->controller('module/successpage',$parameters);
You will get all details of $parameters in index method of your successpage controller file.
That's it. :)
Try this url " [yourhost]/index.php?route=module/successpage" to see if this module is working perfectly. There is no error in loading this module to parent controller. I think issue is present in this module itself. Maybe some value dependency.
I'm using PHRets and trying to return some search results. Below is the code, which is very basic and should work:
include('../include/common.php');
include('../classes/phrets.php');
$rets = new phRETS();
$connect = $rets->connect(RETS_LOGIN_URL, RETS_USERNAME, RETS_PASSWORD);
if($connect){
$search = $rets->SearchQuery('PROPERTY', 'RES', '((COUNTY=Dallas))', array('LIMIT'=>20));
print_r($rets->Error());
echo $rets->TotalRecordsFound($search);
$rets->Disconnect();
}else{
$error = $rets->Error();
print_r($error);
}
When I run the page, I receive the following error:
Array ( [type] => rets [code] => 20203 [text] => The request limit is too large for a GET. Please use the POST method to submit your search. ) 0
I don't see a parameter to force PHRets to send the request as a POST. Will this require a hack of the class, or am I missing something?
Thanks
EDIT: I just heard back from the developer. It's not supported at this time. Perhaps a less-busier person should clone it and work on that.. :) Anyway, if anyone has already has modified the code to make this work, let me know, please.
Get the latest phRETS version which supports POST method from here and replace with your old phrets.php.
then you need to add an extra line to the script
$rets->SetParam('use_post_method', true);
Note: By default it will be GET method.
I've published an updated version supporting POST searches available at https://github.com/nathanklick/PHRETS or via composer by adding "nathanklick/phrets": "1.0.2" to your composer.json file.
Is there anyway to modify the content shown in a SugarCRM Subpanel without relying on Action Hooks?
Right now to edit content for a Subpanel field I have to use the hooks like this...
$hook_array['process_record']
And in the Class method that I assign the Hook to call I can then change a field in the Subpanel like this...
$bean->name = '<a href="/index.php?action=ajaxui#ajaxUILoc=index.php%3Fmodule%3Dproje_Web_Project_Tasks%26action%3DDetailView%26record%3D'
.$bean->id.'" rel="popover" data-content="'
.$bean->description.'" data-original-title="">'.$bean->name.'</a>';
The main and major problem we have with this method is it works great until you do either of these actions....
Add an item using the Quick Create form
Change a page using the Subpanel paging buttons
In either case, it reloads the Subpanel data without running this hook code on the data, so the result is pretty major as the Subpanel fields that you have edited are no longer edited and show up as normal.
Here is a basic example...this shows 2-3 fields that have been edited using the Hook method above...
Now after paging or quick-creating a new record in the Subpanel, it reloads the Subpanel data and does not apply the Hooked code so you can see the result looks like this...
I know that ListView has a much more reliable and flexible method for editing it's content using the get_list_view_data() method I am able to apply the same edits and have them work all the time!
So I am hoping there is a similar method to edit Subpanel data and have it always apply the edits to that data? From what I have seen in my research so far, the only solution that will work as expected all the time, is to make a completely new Custom Field Type!
I am really hoping that is not the ONLY way as that is a major pain to do that for each type of field that I need to edit in the Subpanels and just doesn't feel right when there are easy ways to edit everything else except SubPanel data.
Does anyone have any ideas, suggestions, tips, help, please do share with me on this matter as it is the main problem I have had since I started developing with SugarCRM in the past few months?
You can change the data by writing a custom query to get data for your subpanel.
So inside your bean (this case Contacts) do a functions:
function get_project_list() {
$query = "SELECT project, info, matching, column, names FROM projects WHERE contact_id = '" . $this->id . "' AND deleted = 0"
return $query;
}
and then in subpanel definition set the data source like this:
$layout_defs["Contacts"]["subpanel_setup"]['projects'] = array(
'order' => 10,
'sort_order' => 'desc',
'sort_by' => 'name',
'title_key' => 'LBL_PROJECTS_TITLE',
'subpanel_name' => 'contact_projects',
'module'=>'projects',
'get_subpanel_data' => 'function:get_project_list',
'function_parameters'=>array('type'=>'urgent'), // this is optional if you decide to sent parameters to the function if do this dont forget to define your function with function get_project_list($params)
'top_buttons' => array (... buttons that you need go here..),
);
Since sql is quite powerful you can modify your subpanel data any way you like, well more or less :)