Jump to content

Edit multilanguage page names in custom process module UI


lokomotivan
 Share

Recommended Posts

Hey guys, i built a custom process module so i can edit pages from the custom ui. Everything works great except that multi-language page name fields does't show up in the settings tab when i edit the page from custom ui. See attached image...

I use `executeEdit()` method in my module:

public function executeEdit() {

	// breadcrumb
	$this->fuel->breadcrumbs->add(new Breadcrumb($this->page->url, $this->page->title));

	// Execute Page Edit
   $processEdit = $this->modules->get('ProcessPageEdit');
 	return $processEdit->execute();

}


Any tips? Thanks

no-multilang-page-name.jpg

Link to comment
Share on other sites

@lokomotivan 

public function executeEdit() {

	// breadcrumb
	$this->fuel->breadcrumbs->add(new Breadcrumb($this->page->url, $this->page->title));

	// Execute Page Edit
   $processEdit = $this->modules->get('ProcessPageEdit');
 	return $processEdit->execute();

}

Probably you will use something similar for adding new pages, but with ProcessPageAdd. So, by using this aproach for adding new pages you will get an issue with initial languages values. 

chrome_3xXZAUkFAP.png

As you can see all non-default languages are active.

But, after page save they become disabled.

chrome_CQ3dlp9hZl.png

I was trying to resolve this issue but with no luck. So I went with creating addition page under the module page which reffers to custom module which extend ProcessPageAdd

class ProcessCustomPageAdd extends ProcessPageAdd
{

	/**
	 * @return array
	 *
	 */
	public static function getModuleInfo() {
		return array(
			'title' => __('Page Add', __FILE__),
			'summary' => __('Add a new page', __FILE__),
			'version' => 108,
			'permanent' => true,
			'permission' => 'page-edit',
			'icon' => 'plus-circle',
//			'useNavJSON' => true,
		);
	}

	public function init()
	{
		if ($this->wire('page')->parent->name == 'news-manager') {
			$this->set('parent_id', 1036);
		} else {
				.....
		}

	}

}

Hope it helps.

  • Like 1
Link to comment
Share on other sites

Thanks for the tips @Zeka. Yes having same issue when creating new pages , they are inactive for all other languages. I solved this for now by checking if page is active for another language on page edit, based on language id, eg: $page->status1105

public function executeEdit() {

	// breadcrumb
	$this->fuel->breadcrumbs->add(new Breadcrumb($this->page->url, $this->page->title));

	// Force activate multi-language page variations
        foreach($this->languages as $lng) {
            $id = $this->sanitizer->int($this->input->get->id);
            $p = $this->pages->get("id=$id");
            $status_field = "status{$lng}";
            if($p->{$status_field} != "" && $p->{$status_field} != 1) {
                $p->of(false);
                $p->{$status_field} = 1;
                $p->save();
            }
        }

	// Execute Page Edit
   $processEdit = $this->modules->get('ProcessPageEdit');
 	return $processEdit->execute();

}

In this case i loose ability to deactivate the page for some languages but for now i can live with it. 
Creating a custom add new page is also an option, /module-manager/new/, and writing a custom form for adding new pages and handle it manually. But for page edit is not so easy

Link to comment
Share on other sites

2 hours ago, Zeka said:

@lokomotivan Not sure, but try to implement WirePageEditor by your module class


class YourCustomLister extends Process implements WirePageEditor

 

This solved the issue. Was busting my head a lot THANK YOU @Zeka! ?

Just to note that u also need getPage() method in your module.

class MyModule extends Process implements WirePageEditor {

    public function getPage() {
		return $this->page; 
	}

}
 
Link to comment
Share on other sites

2 hours ago, lokomotivan said:

In this case i loose ability to deactivate the page for some languages but for now i can live with it. 
Creating a custom add new page is also an option, /module-manager/new/, and writing a custom form for adding new pages and handle it manually. But for page edit is not so easy

You don't have to write custom module, you can use ProcessPageEdit as process for that page and omit executeEdit method in your process module.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...