Create data values using php

Events happening in the community are now at Drupal community events on www.drupal.org.
riverrat's picture

Hello
I am not very competent with PHP but understand the basics and have written some code which works!
I am trying to create a component which creates new content and this requires me to set some data values.
The approach I chose was to execute some PHP code to set a data value in a component. I can not use set variable because I wish to allow the user to select from a drop down list of valid variables. The examples here are just setting the variable value
I have tried several approaches but each time the code is ignored.

  • Setting variable name in settings
    For this I added a text field in settings field1
    Then added an execute PHP with the code
    $field1="field 1 content";
    Saved
  • Then created a new action set data value
    Data node:field
    Data selector field1
    Save

    Then when i execute the component using VBO I get a blank entry box to enter the field1 no mention of the code used in the execute PHP .

  • The alternative approach was to set the data value entirely using PHP
    So no added field in settings
    PHP code was simply
    $field1 = "field 1 content";
    In this case again the PHP does not seem to be executed and does not appear in the created content.
  • Comments

    Have you tried using the 'Set

    mitchell's picture

    Have you tried using the 'Set a data value' action?

    Set Data Value

    riverrat's picture

    Thanks for your reply
    I am afraid that my example was only the first part of the problem, so set data value is not suitable.
    What I need to do is to provide a drop-down selection list to chose the value for field 1. Set data value does not allow this type of action, as far as I am aware.
    I am also following the node one course on rules using rules examples, which might be more promising.

    Rules

    Group organizers

    Group categories

    Categories

    Group notifications

    This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: