How to modify buttons on list page? (v2022)

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
btrade
User
Posts: 357

How to modify buttons on list page? (v2022)

Post by btrade »

Hello
I want to modify buttons on list page. I have tried.

$this->OtherOptions["action"]->Items["add"]->Body = "my link";
$this->OtherOptions["action"]->Items["edit"]->Body = "my link";
$this->OtherOptions["action"]->Items["delete"]->Body = "my link";

But it doesn't work in v 2022.

I need to disable buttons and I want to create modify my own buttons. Group buttons and links.


btrade
User
Posts: 357

Post by btrade »

It worked:

$this->ListOptions->Items["view"]->Visible = false; - 

It don't work:

        $this->ListOptions->Items["view"]->Body = 'productsview/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
        $this->ListOptions->Items["edit"]->Body = 'productsedit/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
        $this->ListOptions->Items["add"]->Body  = 'productsadd/'  .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';

       $this->DetailPages->Items["products"]->Visible = false;
       $this->ShowInDropDown = false;

mobhar
User
Posts: 11660

Post by mobhar »

You should refer to the generated code for your references. In other words, you should include the a href syntax for your button links.


btrade
User
Posts: 357

Post by btrade »

I meant something else.

  1. I want to disable the button group for the details wizard. And create separate buttons from these links.
  2. Also I want to disable the add record button. Instead, leave the add button through the details wizard.

arbei
User
Posts: 9292

Post by arbei »

Note that the Body property is HTML, not URL. If you want to change the button, you need to set HTML as <button> or <a> tags.


btrade
User
Posts: 357

Post by btrade »

It doesn't matter to me what my link or button looks like. I want to have only the master link. To add, edit or view information. Now I have a whole set of buttons with and without a master/details. I want everything without the master and leave only the master. I don't need the Master group button.


btrade
User
Posts: 357

Post by btrade »

For example


    $this->ListOptions->Items["view"]->Body = 'productsview/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
        $this->ListOptions->Items["edit"]->Body = 'productsedit/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
        $this->ListOptions->Items["add"]->Body  = 'productsadd/'  .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';

$this->OtherOptions["action"]->Items["add"]->Body = "my Master link";
$this->OtherOptions["action"]->Items["edit"]->Body = "my  Master link";
$this->OtherOptions["action"]->Items["delete"]->Body = "my   Master ink";

I made it like in older version phpmaker.


mobhar
User
Posts: 11660

Post by mobhar »

mobhar wrote:

You should refer to the generated code for your references. In other words, you should include the a href syntax for your button links.

For example (from the generated code):

	// "edit"
	$opt = $this->ListOptions["edit"];
	$editcaption = HtmlTitle($Language->phrase("EditLink"));
	if (true) {
		if ($this->ModalEdit && !IsMobile()) {
			$opt->Body = "<a class=\"ew-row-link ew-edit\" title=\"" . $editcaption . "\" data-table=\"categories\" data-caption=\"" . $editcaption . "\" data-ew-action=\"modal\" data-action=\"edit\" data-ajax=\"" . ($this->UseAjaxActions ? "true" : "false") . "\" data-url=\"" . HtmlEncode(GetUrl($this->EditUrl)) . "\" data-btn=\"SaveBtn\">" . $Language->phrase("EditLink") . "</a>";
		} else {
			$opt->Body = "<a class=\"ew-row-link ew-edit\" title=\"" . $editcaption . "\" data-caption=\"" . $editcaption . "\" href=\"" . HtmlEncode(GetUrl($this->EditUrl)) . "\">" . $Language->phrase("EditLink") . "</a>";
		}
	} else {
		$opt->Body = "";
	}

then you can refer to that code and use it in ListOptions_Rendered server event as follows:

$this->ListOptions["edit"]->Body = "<a class=\"ew-row-link ew-edit\" title=\"Edit\" data-table=\"yourtable\" data-caption=\"Edit\" data-ew-action=\"modal\" data-action=\"edit\" data-ajax=\"" . ($this->UseAjaxActions ? "true" : "false") . "\" data-url=\"" . YourUrlGoesHere . "\" data-btn=\"SaveBtn\">" . Language()->phrase("EditLink") . "</a>";

As you can see, as mentioned above, you need to include the a href tag in your Body property of the Edit item that belongs to the ListOptions object.

(Note: $this->UseAjaxActions is for v2023 only.)


btrade
User
Posts: 357

Post by btrade »

It doesn't work

function ListOptions_Rendered()
{

$YourUrlGoesHere = 'productsedit/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';

$this->ListOptions["edit"]->Body = "<a class=\"ew-row-link ew-edit\" title=\"Edit\" data-table=\"products\" data-caption=\"Edit\" data-ew-action=\"modal\" data-action=\"edit\" data-ajax=\"" . ($this->UseAjaxActions ? "true" : "false") . "\" data-url=\"" . $YourUrlGoesHere . "\" data-btn=\"SaveBtn\">" . Language()->phrase("EditLink") . "</a>";


}

D:\OpenServer\domains\app\office\src\DbTableBase.php(455): Undefined property: UseAjaxActions.

I doesn't need Ajax.


mobhar
User
Posts: 11660

Post by mobhar »

Then you may try the code from the else block:

if (!empty($this->id->CurrentValue)) { // make sure the id is always not empty
    $YourUrlGoesHere = 'productsedit/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
    $this->ListOptions["edit"]->Body = "<a class=\"ew-row-link ew-edit\" title=\"Edit\" data-caption=\"Edit\" href=\"" . $YourUrlGoesHere . "\">" . Language()->phrase("EditLink") . "</a>";
}

btrade
User
Posts: 357

Post by btrade »

Very good , it works. And how can I disable the group button for master, And a button for simple add of records?


btrade
User
Posts: 357

Post by btrade »

 $view = 'productsview/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
     	$edit = 'productsedit/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
    	$add  = 'productsadd/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
        $this->ListOptions["view"]->Body = "<a class=\"ew-row-link ew-view\" title=\"View\" data-caption=\"View\" href=\"" . $view . "\">" . Language()->phrase("ViewLink") . "</a>";
        $this->ListOptions["edit"]->Body = "<a class=\"ew-row-link ew-edit\" title=\"Edit\" data-caption=\"Edit\" href=\"" . $edit . "\">" . Language()->phrase("EditLink") . "</a>";
        
        
        $this->ListOptions["add"]->Body  = "<a class=\"ew-row-link ew-add\" title=\"Add New\" data-caption=\"Add New\" href=\"" . $add . "\">" . Language()->phrase("AddLink") . "</a>"; // 2916 line		

I have the error for an add button
D:\OpenServer\domains\app\office\models\ProductsList.php(2916): Attempt to assign property "Body" on null


mobhar
User
Posts: 11660

Post by mobhar »

There is no add in ListOptions object. It should be copy instead.

So, this code:
$this->ListOptions["add"]->Body = ...

should be:
$this->ListOptions["copy"]->Body = ...


btrade
User
Posts: 357

Post by btrade »

I understood

   $this->ListOptions["copy"]->Body  Instead $this->ListOptions["add"]->Body  

But I don't understand how to hide a group button for Master.


btrade
User
Posts: 357

Post by btrade »

I make it, it works.

$this->ListOptions["details"]->Visible = FALSE; // if you enabled "Multiple detail tables"

It doesn't work on view page.

    $this->OtherOptions["detail"]->Visible = FALSE;

	$view = 'productsview/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
 	$edit = 'productsedit/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
	$add  = 'productsadd/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';

    $this->OtherOptions["view"]->Body = "<a class=\"ew-row-link ew-view\" title=\"View\" data-caption=\"View\" href=\"" . $view . "\">" . Language()->phrase("ViewLink") . "</a>";
    $this->OtherOptions["edit"]->Body = "<a class=\"ew-row-link ew-edit\" title=\"Edit\" data-caption=\"Edit\" href=\"" . $edit . "\">" . Language()->phrase("EditLink") . "</a>";
    $this->OtherOptions["add"]->Body  = "<a class=\"ew-row-link ew-add\" title=\"Add New\" data-caption=\"Add New\" href=\"" . $add . "\">" . Language()->phrase("AddLink") . "</a>";
    $this->OtherOptions["copy"]->Body  = "<a class=\"ew-row-link ew-add\" title=\"Add New\" data-caption=\"Add New\" href=\"" . $add . "\">" . Language()->phrase("AddLink") . "</a>";

D:\OpenServer\domains\app\office\models\ProductsView.php(1303): Attempt to assign property "Body" on null


arbei
User
Posts: 9292

Post by arbei »

There is no $this->OtherOptions["view"] in View page itself.


btrade
User
Posts: 357

Post by btrade »

okay

But it don't working. Page load and page render.

  $edit = 'productsedit/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
  $add  = 'productsadd/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';

  $this->OtherOptions["edit"]->Body = "<a class=\"ew-row-link ew-edit\" title=\"Edit\" data-caption=\"Edit\" href=\"" . $edit . "\">" . Language()->phrase("EditLink") . "</a>";
  $this->OtherOptions["add"]->Body  = "<a class=\"ew-row-link ew-add\" title=\"Add New\" data-caption=\"Add New\" href=\"" . $add . "\">" . Language()->phrase("AddLink") . "</a>";
  $this->OtherOptions["copy"]->Body  = "<a class=\"ew-row-link ew-add\" title=\"Add New\" data-caption=\"Add New\" href=\"" . $add . "\">" . Language()->phrase("AddLink") . "</a>";
$this->OtherOptions["delete"]->Body  = '';

mobhar
User
Posts: 11660

Post by mobhar »

You missed the action part, so try this code:

$edit = 'productsedit/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';
$add = 'productsadd/' .$this->id->CurrentValue . '?showdetail=products_variations,products_variations_colors';

$this->OtherOptions["action"]["edit"]->Body = "<a class=\"ew-row-link ew-edit\" title=\"Edit\" data-caption=\"Edit\" href=\"" . $edit . "\">" . Language()->phrase("EditLink") . "</a>";
$this->OtherOptions["action"]["add"]->Body = "<a class=\"ew-row-link ew-add\" title=\"Add New\" data-caption=\"Add New\" href=\"" . $add . "\">" . Language()->phrase("AddLink") . "</a>";
$this->OtherOptions["action"]["copy"]->Body = "<a class=\"ew-row-link ew-add\" title=\"Add New\" data-caption=\"Add New\" href=\"" . $add . "\">" . Language()->phrase("AddLink") . "</a>";
$this->OtherOptions["action"]["delete"]->Body = '';

btrade
User
Posts: 357

Post by btrade »

It's solved.

And how can I disabled the group button on view page and simple button for adding on list page?


mobhar
User
Posts: 11660

Post by mobhar »

Disable which group button? Did you mean the button group to display menu for Master/Detail View, Master/Detail Edit, and Master/Detail Copy?


Post Reply