Search

Is there a way to access the function that creates Handles for Pages, Text Input, Tag List, Select Box, and Select Box Link within a page template? I would like to take the <input of a persons name, concatenate it with the account number, and save it to the <input in another field. For example name="John Smith" account="123" will yield "123-john-smith". The function would create the handle for only the name. Is it as simple as replace( .. the periods, multiple spaces, and other special characters with a dash?

Not sure if I understand your use case correctly, but I guess Reflection Field would be a good start...

The function converts "John Smith" to "john-smith". The "replace(" I refer to is javascript. Another example would be "John H. Smith" to "john-h-smith". This the handle generated for a TextInput field.

The extension you refer to would concatenate the fields together which I think I've accomplished with javascript.

The extension you refer to would concatenate the fields together which I think I've accomplished with javascript.

Which is what you described above:

I would like to take the <input of a persons name, concatenate it with the account number, and save it to the <input in another field. For example name="John Smith" account="123" will yield "123-john-smith".

So what exactly do you want to achieve next?

For a first post, I'm not doing very well! Is there a way to access the function that creates Handles for Pages, Text Input, Tag List, Select Box, and Select Box Link within a page template? Handles

As far as I remember, functions like the handle creation are indeed accessible via JavaScript, at least in the backend. Didn't find it in the API docs, though. But I guess Brendan can give you more information when he reads this thread, so stay tuned...

Edit: More important question is, why do you want to create handles in JavaScript, when the fields already provide all handles in your XML output?

I'm synchronizing Symphony data with an external program that doesn't operate with a primary key. This combination of account and name will be unique and I can create in in the external program. Comparison of the data from both programs can take place if each entry can be matched with the external program's record. The unique entry needs to take place as the data is stored. User types in name -> function translates name into handle -> concatenate translated name to account number -> store in form.

Symphony provides this function (Symphony API, GitHub) as a helper. You can replicate it in JavaScript if that's your implementation.

The backend makes use of AJAX requests to fetch handles:

var value = 'your string';
$.ajax({
    type: 'GET',
    data: { 'string': value },
    dataType: 'json',
    url: Symphony.Context.get('root') + '/symphony/ajax/handle/',
    success: function(result) {
        // do stuff here
    }
});

I haven't tested it but this should also work from the front-end as long as you attach an authtoken to the URL (and make sure that you hardcode the root as the Symphony object is only available in the backend).

Be aware though, that you expose your backend when using an authtoken publicly.

The unique entry needs to take place as the data is stored. User types in name -> function translates name into handle -> concatenate translated name to account number -> store in form.

Maybe I'm a little slow here, but I still don't get why Reflection Field doesn't already solve your problem. It concatenates the name and the account number into "123 John Smith" and also creates a handle like "123-john-smith" as soon as you save the form. Plus, you can always still access name or account number only via the original fields.

You have finally gotten through my thick skull. Special characters in the primary key concerned me, which is why I came up using the handle. I have successfully tested the ability of the external program and Symphony's ability to deal with those characters. Therefore, the primary key can simply be the Account concatenated with the Name (i.e. "123 John H. Smith") as you have suggested by using the Reflection Field. I do not need the handle at all. I know the handle is still available, but I would not be able to export it via the CSV import/export extension which was part of the original requirements. I am able to use a CSV file comparison tool to see the data changes from Symphony to the external program. The only hurdle left for synchronizing data is the date field format in the extension.

I do not need the handle at all. I know the handle is still available, but I would not be able to export it via the CSV import/export extension which was part of the original requirements.

Allright then. But just in case, even that would be possible by mashing together the field handles (instead of the field values) as new Reflection Field-value.

Thank you for all of your help! The Reflection Field seems very powerful, but unfortunately the git link is down.

The Reflection Field seems very powerful, but unfortunately the git link is down.

http://github.com/symphonists/reflectionfield

Yeah, sorry, we have a bit of a cleanup to do.

I think people's opinion sways towards looking on symphonyextensions.com now which is why we never made sure they were all changed here.

It's all good. Symphony has the best forum and response speed.

Just to complete the discussion about the reflection field. It works flawlessly for user input. However, the import-export csv extension won't import (but it will export) the reflection field. It also would be nice to be able to force it to update after it has been added. The update would fill empty or all fields. In example, it would combine the account and name. I understand the inherent problem with this since it uses an XPath expression.

Perhaps you could modify Resave entries for this purpose.

No modification necessary. It fits the requirement perfectly. Import is not necessary with this extension. Design pattern for a two field primary key used for csv comparison is to download Resave entries and Reflection field then use a CSV Tool to compare. You can verify both systems are synchronized.

Have you achieved you objective?

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