I have following code:
return array(
ULogt::UPDATE => '
<div>
Navigate
</div>
'
This code locates in the class called links.php.
I need to navigate to ('viewform', array('model'=>$this->loadJson($id)), when the user presses Navigate button. I do not know how to insert this code instead of #link. How can I do it?
CHtml::link(
"Navigate",
"javascript:void(0);", // link for destination or you can handle same with jQuery
array(
'id' => 'navigation-id', // id for handeling in jQuery
'key' => $data, // Required data will be appeared as attributes for this link
)
);
You can create link like
Yii::app()->createUrl(
'/profile/membership/view', // your link
array(
'id'=> 1 // data to be sent
)
)
Check for URL formating
Related
Is it possible to add a custom button that downloads pdf ?
ive tried doing it but i only get create button from this example: Link here
'searchInputs' => array(
1 => 'payment_date',
2 => 'payment_stage',
3 => 'or_no',
),
'create' =>
array(
'formBase' => 'PrintPayment.php',
'formBaseClass' => 'PrintPayment',
'getFormBodyParams' => array('', '', 'PrintPaymentSave'),
'createButton' => $mod_strings['LNK_NEW_PAYMENT']
),
is there any other way to add a download functionality ?
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/SugarObjects/forms/FormBase.php');
class PrintPayment extends FormBase {
var $moduleName = 'PrintPayment';
var $objectName = 'PrintPayment';
function handleSave($prefix, $redirect=true, $useRequired=false){
require_once('include/formbase.php');
$focus = new PrintPayment();
$focus = populateFromPost($prefix, $focus);
$focus->save();
}
}
is there any experts who knows this ? thanks in advance.
First you need to go to dropdown editor in admin panel and find "pdf_template_type_dom".
It's list responsible for modules available in PDF - templates module.
After adding module of your choice to the list you might need to rebuild the app.
After you add module, create a some template for it.
Afterwards you need to modify your viewdefs in your module to add the button allowing for PDF print. Here is custom code for the button:
array ( 'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');" value="PDF">'
Add the button somewhere and voila.
I tested in DetailView for my custom modules but the principle should be the same.
tl;dr; Trying to link the 'save and return' button when editing/deleting a course to my local plugins index.php instead of moodles default redirect for these features, moodle allready has a returnTo query parameter so i was thinking if that could be used somehow.
Hey
I am creating a local plugin that has a administration panel, where you can access CRUD on all courses in the system as seen in the picture below:
The problem now is that whenever I click edit, I get into the course edit page of course, but when I return from there I click "save and return" I would like to get back to my own admin page instead of the course page or category manage page.
The code I have right now looks like this:
//edit
$edit_course_moodle_url = new moodle_url('/course/edit.php', array('id' => $course->id, 'returnto' => 'local/adminpanel/index.php'));
$edit_course_url = $edit_course_moodle_url->get_path() . '?id=' . $edit_course_moodle_url->get_param('id') . '&returnto=' . $edit_course_moodle_url->get_param('returnto');
//delete
$delete_course_moodle_url = new moodle_url('/course/delete.php', array('id' => $course->id, 'returnto' => 'local/adminpanel/index.php'));
$delete_course_url = $delete_course_moodle_url->get_path() . '?id=' . $delete_course_moodle_url->get_param('id') . '&returnto=' . $delete_course_moodle_url->get_param('returnto');
As you can see I use the "returnto" query parameter, normally moodle has a "catmanage" as "returnto" that returns you to the category management page, where moodle has its own CRUD for categories and courses. So my question is, can I create my own alias for a link and use it like moodle uses the catmanage link, but for my admin page instead.
Thanks a lot ! :)
EDIT:
Change code to the following:
if (empty($CFG->loginhttps)) {
$securewwwroot = $CFG->wwwroot;
} else {
$securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
}
$returnurl = new moodle_url($securewwwroot . '/local/adminpanel/index.php');
$edit_course_moodle_url = new moodle_url($securewwwroot . '/course/edit.php', array(
'id' => $course->id,
'sesskey' => sesskey(),
'returnto' => 'url',
'returnurl' => $returnurl->out(false))
);
$edit_course_url = $edit_course_moodle_url->out();
But it looks like moodle took away the button from edit course called "save and return" now it only has "save and display" or "Cancel" , both of which brings me back to the course, sad times :(
According to the code I can see in course/edit.php, you should use the following URL arguments:
returnto: 'url'
returnurl: The url
sesskey: sesskey()
In code that gives us:
$returnurl = new moodle_url('/local/plugin/page.php');
$editurl = new moodle_url('/course/edit.php', array(
'id' => 2,
'sesskey' => sesskey(),
'returnto' => 'url',
'returnurl' => $url->out(false)
));
echo $editurl->out();
The page course/delete.php does not seem to support those arguments. But it's probably easier for your plugin to delete the course by itself, it's as simple as calling delete_course($courseid);.
I am using Yii and showing the data on front end . I have a field for status (active or not). I am displaying in grid view like this
array(
'class' => 'CCheckBoxColumn',
'selectableRows' => 2,
'header'=>"Status",
'checked'=>function($data, $row) use ($current_reviewers)
{
return in_array($data->rem_status, $current_reviewers);
}
),
it is displaying the data correctly . But it is showing the checkbox in the column heading like in the link link to image.
thanks
'selectableRows'=>2 will put a checkbox in the header . Please remove that line and try
Assume I'm in my items controller.
Ok say I am in my view action (the url would be something like /items/view/10012?date=2013-09-30) which lists a list of items that belongs to a client on a given date.
I want to link to add a new item. I would use the htmlhelper like so:
echo $this->Html('action'=>'add');
In my add action I have a form which has fields like client_id and item_date.
When I'm in my view action I know these values as I am viewing the items for a specific client on a specific date. I want to pass these variables to my add action so it will prefill those fields on the form.
If I add a query string in my link ('?' => array('client_id'=>$client_id)) it breaks the add action as it will give an error if the request is not POST. If I use a form->postLink I get another error as the add action's POST data must only be used for adding the record, not passing data to prefill the form.
I basically want to make my link on the view page pass those 2 variables to the add action in the controller so I can define some variables to prefill the form. Is there a way to do this?
Here is my add controller code. It may differ in content a bit from my question above as I have tried to simplify the question a bit but the concept should still apply.
public function add(){
if ($this->request->is('post')) {
$this->Holding->create();
if ($this->Holding->save($this->request->data)) {
$this->Session->setFlash(__('Holding has been saved.'), 'default', array('class' => 'alert alert-success'));
return $this->redirect(array('action' => 'index'));
}
$this->Session->setFlash(__('Unable to add your holding.'), 'default', array('class' => 'alert alert-danger'));
}
$this->set('accounts', $this->Holding->Account->find('list'));
$sedol_list = $this->Holding->Sedol->find('all', array(
'fields' => array(
'id', 'sedol_description'
),
'recursive' => 0,
'order' => 'description'
)
);
$this->set('sedols', Hash::combine($sedol_list, '{n}.Sedol.id', '{n}.Sedol.sedol_description') );
}
Why not use proper Cake URL parameters?
echo $this->Html->link('Add Item', array(
'action' => 'add',
$client_id,
$item_date
));
This will give you a much nicer URL like:
http://www.example.com/items/add/10012/2013-09-30
And then in your controller, you modify the function to receive those parameters:
public function add($client_id, $item_date) {
// Prefill the form on this page by manually setting the values
// in the request data array. This is what Cake uses to populate
// the form inputs on your page.
if (empty($this->request->data)) {
$this->request->data['Item']['client_id'] = $client_id;
$this->request->data['Item']['item_date'] = $item_date;
} else {
// In here process the form data normally from when the
// user has submitted it themselves...
}
}
So I have this part in my View:
<body>
<div id = "content">
<?php echo $catalog ?>
</div>
</body>
There are also other variables in it. Here is the part of my Controller where I send them to the View:
$this->load->view('layout',array(
'categories' => $categories,
'home_menu' => $home_menu,
'information' => $information,
'favourite' => $favourite,
'new_products' => $new_products,
'bestsellers' => $bestsellers,
'login_info' => $login_info,
'catalog' => ''
));
I want to create second controller, which when activated sends a second view to the variable $catalog.
Something like this (similar to Kohana):
$this->layout->catalog = $this->load->view('products/catalog', array(
'name' => $name,
'description' => $description));
But it's not working.
My question is, how can I show this second nested view after clicking on a link that activates the second Controller?
EDIT:
But I want to send the catalog view to $catalog variable after the user has clicked on a link that activates second controller, which look something like this:
$products = $this->Product_model->list_products($category_id);
foreach ($products as $row)
{
$name = $row->name;
$description = $row->description;
}
.. after that I want $name and $description to be passed to:
$this->load->view('products/catalog', array(
'name' => $name,
'description' => $description));
..which itself to be passed to $catalog in the layout view defined in the first controller
You can call a $this->load->view within the view's code but I would not recommend it.
Instead pass true as the 3rd parameter in the load view function and this will return the view rather than echo it straight out. Then you can assign that returned code to your original view.
I'm hoping I'm understanding your question fully, but if not, I apologize.
My guess is that you're loading the page with all of the 'extras' and want to be able to update the 'content' part of your page through a user initiated click.
If you're implementing a javascript based solution, then you just need a controller that will output the html fragment and inject that into the current page via an ajax call.
If you're not implementing javascript, then it would be an entire page refresh, so you would just rebuild the page and pass the selected catalog content to the controller.
UPDATE
To do this without ajax or hmvc, you need to get the contents from another controller into this controller, so you could just make an additional request with php:
$catalog_content = file_get_contents('/url_to_second_controller.html');
$this->load->view('layout',array(
'categories' => $categories,
'home_menu' => $home_menu,
'information' => $information,
'favourite' => $favourite,
'new_products' => $new_products,
'bestsellers' => $bestsellers,
'login_info' => $login_info,
'catalog' => $catalog_content
));