add custom button in toolbar on view page

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
vikash
User
Posts: 17

add custom button in toolbar on view page

Post by vikash »

i want to add custom button on view page in the line of toolbar.
i tried but button is coming below the toolbar.
i was used page_datarendering() for this problem but it dint work properly.
anybody can help...........??


mobhar
User
Posts: 11709

Post by mobhar »

Simply put the following code in "Page_Render" server event that belongs to the "View Page":

$options = &$this->OtherOptions; // use OtherOptions
$option = $options["action"]; // part of action button
$item = &$option->Add("my_new_button"); // <--- adjust it to yours
$item->Body = '<a class="btn btn-default ewAction ewEdit" title="My Home" data-caption="My Home" href="home.php"><span data-phrase="My Home" class="glyphicon glyphicon-home ewIcon" data-caption="My Home"></span></a>'; // <-- adjust it to yours


vikash
User
Posts: 17

Post by vikash »

its working fine.....but i want to use in list page and change button position also.


mobhar
User
Posts: 11709

Post by mobhar »

Simply put the following code in "Page_Render" that belongs to the "List Page":

$item = &$this->SearchOptions->Add("my_new_button");
$item->Body = '<a class="btn btn-default ewAction ewEdit" title="My Home" data-caption="My Home" href="home.php"><span data-phrase="My Home" class="glyphicon glyphicon-home ewIcon" data-caption="My Home"></span></a>'; // <-- adjust it to yours


sangnandar
User
Posts: 980

Post by sangnandar »

Search this forum for "ListOptions_Load" and "ListOptions_Rendered"


vikash
User
Posts: 17

Post by vikash »

can i use same code in master/detail view page for hiding button from toolbar?

I want to hide button from toolbar in master/detail table on view page(detail page).


sangnandar
User
Posts: 980

Post by sangnandar »

Yes you can.
The logic goes this way:

  1. Check whether the page is in master/detail mode.
  2. Do your code based on that condition.

There are plenty ways to check the condition. Search this forum for "getCurrentMasterTable". You can also use isset($_GET[EW_TABLE_SHOW_MASTER]). Or any other ways that fit your code well.


vikash
User
Posts: 17

Post by vikash »

vikash wrote:
thanks...i got it.


Post Reply