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

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

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

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: 11756

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: 11756

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.


philmills
User
Posts: 568

Post by philmills »

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?


mobhar
User
Posts: 11756

Post by mobhar »

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.


philmills
User
Posts: 568

Post by philmills »

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


SOHIB
User
Posts: 97

Post by SOHIB »

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 =  '<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

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


mobhar
User
Posts: 11756

Post by mobhar »

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.


Post Reply