Using $CPF_LIST w/ fractional editing

Post

Posted
Rating:
#3638 (In Topic #710)
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
I'm using fractional editing with a CPF that contains list type values. In order to display these values automatically, I think I need to use $CPF_LIST to return all possible values of my CPF.

According to the documentation, fractional editing requires a list separated by a |

$CPF_LIST returns all values separated with a comma and oddly repeats the value. Example:

Code

value1=value1,value2=value2,value3=value3, etc.

I imagine I can surround $CPF_LIST with $REPLACE to replace the commas with |, but I'm not sure how to remove the value= part (CPF values all contain different amounts of characters as well).

Online now: No Back to the top

Post

Posted
Rating:
#3681
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
This is really pushing at the edges, but I got it to work.

First, I had to make a few fixes:
https://github.com/ocproducts/composr/commit/8e947c532181155ea698b1185b308562162121ea

Then I did it like:

Code

{$SET,edit_type,{$SUBSTR,{$PREG_REPLACE,(^|\,)([^=]*)=([^\,]*),|$2,{$CPF_LIST,Currency code}},1}}

(I just used Currency code as that is a default CPF with a list that I could test with).


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3682
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Actually, I think it is better I just code CPF_LIST to support different output.

https://github.com/ocproducts/composr/commit/71cfbb817a99646226541f2719fd3b96326d8473

Code

{$SET,edit_type,{$CPF_LIST,Currency code,|,0}}


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3949
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Chris,

This was working but no longer does. Not sure what happened. Instead of showing a dropdown, it just shows a text field now, almost like it's ignoring $SET.

I don't recall upgrading my installation since you've posted this. It's possible but I'm unsure. I compared both CPF_LIST.php on Github and in my installation, they are both the same.

Is it possible something else could've affected this?

It's not too big of a deal - I'd rather it be dynamic in case I make a change to one of the CPF drop down values so then it'll update on its own when using fractional editing, but worse case scenario I can just manually hard code the drop down values.
Online now: No Back to the top

Post

Posted
Rating:
#3950
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Nevermind,

What happened was I created a new theme and doing so somehow reverted the changes to FRACTIONAL_EDIT.tpl, so it wasn't using $GET to retrieve the edit_type.

It's fixed now. Sorry.
Online now: No Back to the top
1 guest and 0 members have just viewed this.
Back to Top