Search

Even if I look at it many times, if I don't get how textareas are saved, or what is excepted from this method, it is leading nowhere. :S

Knowing that the entries unformated are correct, and that I only need to recall the formatter, isn't there a generic way to do it ?

It seems that only the ones who have made extensions know how things work :/

So which textformatter you need to call?

I have created a class called formatterBBCode.

And the transformer in it is as simple as the following :

public function run($string){
        return BBCode2Html($string);
    }

I guess something like this should work then.

Follow the same steps posted before, changing the callback to toBBCode.

The code has worked but not as expected. It has transformed the source code (BBcode) into HTML which isn't wanted. I want to transform only the formatted field.

Hopefully I did a backup just before, so I haven't lost my data :p.

If I have well understood what u did : I have to replace

$data['entry']->setData($field_id, array('value' => $string));

by

$data['entry']->setData($field_id, array('value_formatted' => $string));

isn't it ?

Yeah, probably :D

tx Marco, that works nice now and is very usefull :)

I just advice you to put some example code such as the following into callback.php :

// use the name of the method on the callback input field into preferences
function callbackMethod($data) {
    // 25 is the id of the textarea you wanna update after having changed the formatter
    callbackMethod($data, 25);
    // if you have many text areas you can call the method with as many id
    //   from different sections as far as it's the same transforming method
    //callbackMethod($data, 48);
    //callbackMethod($data, 60);
}

function callbackMethod($data, $field_id) {
    // retrieve field's data 
    $fieldData = $data['entry']->getData($field_id);

    // works only if the field exists into the section to update
    if (!is_null($fieldData)) {
        // textareas fields are saved on database using 2 different fields
        // - 'value' which is equivalent to : unformatted
        // - 'value_formatted' which is equivalent to : formatted

        // recovering the field's value
        $unformatted = $fieldData['value'];

        if (!is_null($unformatted)) {
            // call the transforming method
            $formatted = transfomMethod($unformatted);
            // updates the formatted value of the field's data
            $data['entry']->setData($field_id, array('value_formatted' => $formatted));
        }
    }
}

Thanks for the advice! Will update that soon.

Im trying to use this to update a system ID field I added to a section with 2000+ entries.

Im not sure how to write a call back script for such a field.

Can anyone help me please ?

When i just run it out of the box it resaves but nothing is changed

edit: oh yea im on 2.2.2

@alpacaaa - Have you used this extension with Symphony 2.2.5? Since I upgraded to the latest Symphony, now when I click on Resave entries, it just says "Processing..." and doesn't do anything.

FYI... I've used this extension successfully with both 2.2.3 and 2.2.4.

Thanks for reporting, will look into that in a few days.

Just tested in 2.2.5 and it works fine. It would be helpful if you could post the error thrown in the ajax request that the extension makes under the hood (just copy and paste what you see in firebug console).

Sorry. It works fine. It seems to be a weird cache issue in my browser. My mistake. Thanks for checking.

Ok cool.

Is this extension working on textarea's?
I have imported formatted text with import csv extension,
after importing i need to resave the entrie in order to make the formatting work.
I need to do this for 2500 entries, so this extension seems perfect for that and would save me day's of work.... but after running the extension nothing happened, the formatting is still not right :(
Manualy resaving works though... I am using this in symphony 2.2.5.

Have you tried setting the number per page rather low? (You might have run into a memory issue.)

The extension is working fine, exept for the textarea
I am using CKeditor: compact
The only difference after saving the record is the processed xml (i've set my page to 'xml')
The markup in the textfield looks exactly the same...
Here's the markup and xml before and after resave:

Before save:

markup in textfield:

<p>Rustige werking door geharde en geslepen tandwielen<br />
Gegarandeerde nauwkeurigheid van ? 0,02 mm aan de Pinole<br />
Breed toerentalbereik 75-2020 omw / min (12 stappen) voor optimale werking<br />
Koelmiddelinrichting en verlichting is standaard<br />
Rechts en links draaien van de spindel voor Tappen/draadsnijden<br />
3 automatische voedingen met electromagnetische koppeling<br />
Tafel in de horizontale kolom om het draaibaar, kantelbaar met 45&#176; rechts en links<br />
Grond plaat met T-gleuven voor de bevestiging van lange werkstukken</p>

output xml page:

<omschrijving>Rustige werking door geharde en geslepen tandwielenGegarandeerde nauwkeurigheid van ? 0,02 mm aan de PinoleBreed toerentalbereik 75-2020 omw / min (12 stappen) voor optimale werkingKoelmiddelinrichting en verlichting is standaardRechts en links draaien van de spindel voor Tappen/draadsnijden3 automatische voedingen met electromagnetische koppelingTafel in de horizontale kolom om het draaibaar, kantelbaar met 45° rechts en linksGrond plaat met T-gleuven voor de bevestiging van lange werkstukken</omschrijving>

After save:

markup in textfield: (no changes here)

<p>Rustige werking door geharde en geslepen tandwielen<br />
Gegarandeerde nauwkeurigheid van ? 0,02 mm aan de Pinole<br />
Breed toerentalbereik 75-2020 omw / min (12 stappen) voor optimale werking<br />
Koelmiddelinrichting en verlichting is standaard<br />
Rechts en links draaien van de spindel voor Tappen/draadsnijden<br />
3 automatische voedingen met electromagnetische koppeling<br />
Tafel in de horizontale kolom om het draaibaar, kantelbaar met 45&#176; rechts en links<br />
Grond plaat met T-gleuven voor de bevestiging van lange werkstukken</p>

output xml page:

<omschrijving>Rustige werking door geharde en geslepen tandwielen
Gegarandeerde nauwkeurigheid van ? 0,02 mm aan de Pinole
Breed toerentalbereik 75-2020 omw / min (12 stappen) voor optimale werking
Koelmiddelinrichting en verlichting is standaard
Rechts en links draaien van de spindel voor Tappen/draadsnijden
3 automatische voedingen met electromagnetische koppeling
Tafel in de horizontale kolom om het draaibaar, kantelbaar met 45° rechts en links
Grond plaat met T-gleuven voor de bevestiging van lange werkstukken
</omschrijving>

So the only changes after a manual resave seem to be the linebreaks in the output xml, and i need these linebreaks.

This transformation does not take place with the resave extension
Do i need to write a callback function for the ckeditor field?

Sorry, I don't know anything about the ckeditor extension. I never used it.

Maybe someone else can give a hint what goes wrong here?

Maybe someone else can give a hint what goes wrong here?

Hopefully, not really looking forward doing this manualy...

I solved it with xslt for now, by replacing <br /> with &#xa; to get all the linebreaks in the output xml
So luckily i don't have to resave every entry manualy... :) I still don't understand why this extension is not resaving the textarea...
So if anyone has a clue i'd still like to know...

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details