54 Posts
nzimas
8 years ago
Topic

Is it possible to generate the article title from the article ID + a variable text string taken from another field without using the SD Live Field plugin?

The output should look like "Request #123 - Blah Blah Blah".

I've tried to at least get the article ID from the Live URL Variable modifier, but to no avail.

Get a Book for SEBLOD
1283 Posts
Bucklash
8 years ago
10
Level 1

Hi

You need the Afterstore field/plugin.

You have no Article ID until it is stored (If editing the article then you can use BeforeStore as ID will be available).

Lionel's Tutorial does the trick changing-the-joomla-message-after-a-submission-of-a-seblod-form

or go hardcore Joomla:

Inserting,_Updating_and_Removing_data_using_JDatabase

Bucklash

54 Posts
nzimas
8 years ago
9
Level 2

Thank you so much for the valuable pointer.

I've tried to adapt one of the simplest examples, but it s not doing the job.

$name = $fields['art_title']->storage_field; 
$table = $fields['art_title']->storage_table;
$new_value = $config['pk'];
$config['storages'][$table][$name] = $new_value;
$fields['art_title']->value = $new_value;

This same block of code works in the BeforeStore field if $new_value = 'fixed_value';.

83 Posts
CAF St Brieuc
8 years ago
8
Level 3

Hello nzimas

I use this to change the art_title

$config['storages']['#__content']['title']= $new_value;

best regards

G.Bob

54 Posts
nzimas
8 years ago
7
Level 4

But where do you define $new_value so that it picks the value from art_id?

1283 Posts
Bucklash
8 years ago
6
Level 5

Hi

Try:

$new_value = $fields->getValue('art_title'); // or getHtml etc

54 Posts
nzimas
8 years ago
5
Level 6

Shouldn't it be $new_value = $fields->getValue('art_id'); to get the article id?

1283 Posts
Bucklash
8 years ago
0
Level 7

Sorry

Yes :)

83 Posts
CAF St Brieuc
8 years ago
3
Level 7

Hi

see that : http://www.seblod.com/resources/tutorials/changing-the-joomla-message-after-a-submission-of-a-seblod-form

And use AfterStore process because BeforeStore your id doesn't yet exist !

best regards

54 Posts
nzimas
8 years ago
2
Level 8

I find the example provided at http://www.seblod.com/resources/tutorials/changing-the-joomla-message-after-a-submission-of-a-seblod-form

far too confusing and not readily adaptable (please understand that my knowledge of PHP is somewhat limited :().

In my most recent  attempt, i've tried:

$new_value = $fields->getValue('art_id'); 

$config['storages']['#__content']['title']= $new_value;

But ended up with a PHP fatal error.

Wondering if $config['pk']; must be stated somewhere, as it refers to the unique ID of the content item.

83 Posts
CAF St Brieuc
8 years ago
1
Level 9

hi,

ok I make a mistake, you can't do that in afterstore process check here.

but you can do that :


$blabla = $fields['art_title']->value;
$new_value = 'Request #' . $config['pk'] . ' - ' . $blabla;

$sql = 'UPDATE #__content SET title="' . $new_value . '" WHERE id=' . $config['pk'];
$db = &JFactory::getDBO();
$db->setQuery($sql);
$db->query();

Maybe it's not the good way, but it's work

54 Posts
nzimas
8 years ago
0
Level 10

@CAF St Brieuc

Thanks a million for your invaluable help! 

The art_title field is finally taking its value from the pk of the entry.

Get a Book for SEBLOD