• Resolved TradeMalia

    (@trademalia)


    Hello,

    I was trying to follow these instructions for nested spintax

    https://ww.wp.xz.cn/support/topic/nested-spin-function/

    I have some fields in my CSV file with variable data, wich are included in the spintax, but the data are not correctly recognized.

    For example, I’ve included this line:

    [my_process_spintax(“{La mejor|La|La última} {options[1]}”)]

    In my CSV file ‘options[1]’ has 3 lines:

    – Oferta
    – Novedad
    – Variedad

    Thus, the expected result should be:

    “La mejor oferta”

    or…

    “La última novedad”

    etc….

    Instead of that, The result is:

    “La mejor options[1]”

    or

    “La última options[1]”

    etc….

    I supose the problem is because the field’s key of my csv is inluded inside the quotation marks, and I need how to resolve this problem, because in some cases I need to spin the results with several fields options

    for example:

    [my_process_spintax(“{La mejor|La|La última} {{options[1]}|{options_2[1]}|{options_3[1]}}”)]

    Thank you in advance for helping me!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @trademalia,

    I supose the problem is because the field’s key of my csv is inluded inside the quotation marks, and I need how to resolve this problem, because in some cases I need to spin the results with several fields options

    You would need to pass the import fields to a custom function that generates the spintax and returns it. Here’s a rough example that you can modify as needed:

    function my_custom_spintax( $text1 = '', $options ) {
    	$output = '';	
    	$output .= my_process_spintax( $text1 ) . ' ';	
    	$options = '{' . implode( '|', $options ) . '}';	
    	$output .= my_process_spintax( $options );	
    	return trim( $output );
    }

    Used like so:

    [my_custom_spintax("{La mejor|La|La última}",array({options[1]},{options_2[1]},{options_3[1]}))]

    Thread Starter TradeMalia

    (@trademalia)

    Hello,

    Thank you for the reply, but I think that code doesn’t resolve my problem. I have the import fields in my text and in some cases they are spun as well.

    Probably I haven’t explained correctly. I give you a real example. This is how the import fields are included in my text:

    https://prnt.sc/umm33b

    This is the result:

    https://prnt.sc/umm3v7

    And the desired result should be this one:

    https://prnt.sc/umm556

    I appreciate you wrote for me that PHP function, but I think that code doesn’t resolve my problem.

    thanks!
    Caio

    • This reply was modified 5 years, 8 months ago by TradeMalia.
    Plugin Author WP All Import

    (@wpallimport)

    Hi @trademalia,

    The solution is still similar – any time you need to use import elements in a function, they need to be passed as arguments to the function rather than inside the text. So, for example, you could do something like:

    [my_custom_spintax("{La mejor|La|La última} blah blah ***INSERTELEMENTHERE***",array({plural[1]},{pluralmin1[1]}))]

    Then, adjust the code so that it spins the text, then spins {plural[1]}|{pluralmin1[1]} and replaces ***INSERTELEMENTHERE*** with the result when returning the spun text.

    Plugin Author WP All Import

    (@wpallimport)

    @trademalia, I’m marking this as resolved since it’s been a while. Let us know if you still have questions.

    Anyone else, please open a new topic.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Variable Data not recognized with nested spintax’ is closed to new replies.