add new object subtype pages

Hello, i like add new object of plugin pages for a group.this is correct??

the group guid are 857

$object = new ElggObject();
$object->subtype = 'page_top';
$object->description = 'lore ipsum';
$object->container_guid = '857';

$object->save();

 

thanks!!!

  • $object->title = $title;

    $object->owner_guid = elgg_get_logged_in_user_guid();

    $object->access_id = ACCESS_PUBLIC;

  • I'm sorry but dont work.i understand I had to add what you said:

    $object = new ElggObject();
    $object->subtype = 'page_top';
    $object->description = 'lore ipsum';
    $object->container_guid = '857';

    $object->title = $title;

    $object->owner_guid = elgg_get_logged_in_user_guid();

    $object->access_id = ACCESS_PUBLIC;

    $object->save();

     

    i think that the problem is in subtype??

    thanks!!

  • I think the statement should be like this:

    $object = new ElggObject();
    $object->subtype = 'page_top';
    $object->description = 'lore ipsum';
    $object->group_guid = '857';

    $object->access_id = ACCESS_PUBLIC;

    $object->save();

    Rodolfo Hernandez

    Arvixe/Elgg Community Liaison

  • Also, container guid should be an integer, not a string.  Not sure if that makes a difference, but it should be an integer.

  • i'm sorry but dont work :(

  • You need to be a bit more descriptive with *what* exactly isn't working.  Otherwise we can't be of any more help.

  • please, sorry matt.

    i use this code:

    $object = new ElggObject();
    $object->subtype = 'page_top';

    $object->title = 'title 1';

    $object->description = 'lore ipsum';

    $object->group_guid = 127;

    $object->access_id = ACCESS_PUBLIC;

    $object->save();

     

    It really does not explain anything very well as you for information, have one error :

         - The main page of pages/all appears blank.

    but really I have no more information, look in phpadmin but do not identify the error.

    If i  see on screen the value of $object gives me the following:

     

    ElggObject Object
    (
    [url_override:protected] =>
    [icon_override:protected] =>
    [temp_metadata:protected] => Array
    (
    )

    [temp_annotations:protected] => Array
    (
    )

    [temp_private_settings:protected] => Array
    (
    )

    [volatile:protected] => Array
    (
    )

    [attributes:protected] => Array
    (
    [time_created] =>
    [guid] => 158
    [type] => object
    [subtype] => 11
    [owner_guid] => 0
    [container_guid] => 0
    [site_guid] =>
    [access_id] => 2
    [time_updated] =>
    [last_action] =>
    [enabled] => yes
    [tables_split] => 2
    [tables_loaded] => 0
    [title] => title 1
    [description] => lore ipsum
    )

    [valid:protected] =>
    )

    very very

    very thanks!!!

  • [owner_guid] => 0
    [container_guid] => 0

     

    You didn't give it a valid owner/container - you're probably getting a white screen because php is trying to render a non-existant owner.

  • is true!!thanks but i dont know that resolve this.

     

     

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking