Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

afterPageCreate and afterPageModify not compatible with CustomFields #1480

Open
G3N-es opened this issue Dec 15, 2022 · 0 comments
Open

afterPageCreate and afterPageModify not compatible with CustomFields #1480

G3N-es opened this issue Dec 15, 2022 · 0 comments

Comments

@G3N-es
Copy link

G3N-es commented Dec 15, 2022

Describe your problem

When I use the example function with customFields enabled, the customFields information is not saved and is deleted.

Steps to reproduce the problem

Using the example plugin with valid customFields
https://docs.bludit.com/en/plugins/pages-after-creation

Bludit version

3.14.1.

Hosting or Webserver name

x10hosting

PHP version

PHP version: 7.4.16

SOLUTION

The example uses the wrong method for the intended purpose.
$pages->edit()

The correct method is
$pages->setField()

#My example

<?php
class TitleAppender extends Plugin {
	
	public function afterPageModify($key)
    { 
        $page = new Page($key);
        $Custom = $page->getValue('custom');
        $Type = array('Type'=>array());
		array_push($Custom, $Type);
	    global $pages;
        $pages->setField($key,'custom', $Custom);
    }

}
?>

I want to add a note, Bludit never ceases to amaze me, how simple and powerful.

These functionalities (afterPageCreate and afterPageModify) are very powerful for creating content type plugins. And it's worth it to get it working properly. If it messes up the user's possible customFields, it won't be very reliable.

The potential is enormous, because it allows you to create almost any project (e-learning, ecommerce....) with little code, extending Pages as contenTypes, an extended class of Pages which will conveniently filter the content before output..
For a simple frontend output just replace the global $Pages with $Pages= new customTypes() ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant