How to add custom button in toolbar on View page? (v2017)

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…??

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 = ‘’; // ← adjust it to yours

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

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

Search this forum for “ListOptions_Load” and “ListOptions_Rendered”

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).

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 wrote:
thanks…i got it.

I would like to add a custom button to all pages and views where the toolbar is displayed.
Can I do that globally somehow, or do i have to add it on each page seperately?

If you meant “toolbar” is the line section where the Export buttons are located, then you should add it on each page separately.However, if you meant “toolbar” is the navbar section, then you may use Page_Foot server event to add that custom button by customizing the navbar section.

I ended up adding toolbar buttons to the navbar section, it was easier.
Thanks

mobhar wrote:

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

$item = &$this->SearchOptions->Add(“my_new_button”);
$item->Body = ‘’; // ← adjust it to yours

>

Hi
i have try to use the above code in page_Render  list page (version 2020)
but the button not apear with me
what is the resone

The code I posted above was on year of 2017, perhaps that for PHPMaker v2018. It was probably not compatible with the version 2020 and the latest version.

Is this code from mobhar working in V2024?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

You may try for v2024 in Page_Render server event that belongs to the View Page:

$basePath = BasePath(true); // <-- you need this, and include it in a href below
$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="ew-action ew-add" href="' . $basePath . 'home"><i class="fa-solid fa-home ew-icon"></i>Home</a>'; // <-- adjust it to yours