Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-03-22 11:38:38

polmoneys
New Member
Registered: 2018-03-22
Posts: 2

Friendly way to feed data to front end javascript ?

I’m using parcel.js to build the front end and using react.js for some parts of the site.

I need a way to update an array of ‘objects’ that is more friendly for the content creator/manager of the site than my current (silly) solution:

- creator add objects to a custom form

Then ‘import’ the form on the page that will be consuming it:

<script>
var data = [<txp:article_custom form="data" />];
// data contains the array, react takes over
</script>

I don’t want to create an article for each ‘object’, if that makes any sense…how have you been doing it ?

TIA

Offline

#2 2018-03-22 12:43:31

etc
Developer
Registered: 2010-11-11
Posts: 5,082
Website GitHub

Re: Friendly way to feed data to front end javascript ?

Hello, welcome to the forum.

I’d say it depends on objects. If they are rather “atomic”, <txp:output_form /> containing all the objects could suffice, but is not very user-friendly. Otherwise, what’s wrong with them being articles?

In 4.8 we’ll hopefully have a more flexible articles structure, with customizable fields.

Offline

#3 2018-03-22 13:50:39

polmoneys
New Member
Registered: 2018-03-22
Posts: 2

Re: Friendly way to feed data to front end javascript ?

etc wrote #310246:

Hello, welcome to the forum.

I’d say it depends on objects. If they are rather “atomic”, <txp:output_form /> containing all the objects could suffice, but is not very user-friendly. Otherwise, what’s wrong with them being articles?

In 4.8 we’ll hopefully have a more flexible articles structure, with customizable fields.

There is actually nothing wrong with them being articles, gracias !

Offline

Board footer

Powered by FluxBB