Skip Navigation

[Gelöst] Get a view output with no empty space to build a shortcode

This support ticket is created vor 7 Jahre, 9 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Supporter timezone: Asia/Karachi (GMT+05:00)

Dieses Thema enthält 3 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von mohamed-saadC vor 7 Jahre, 9 Monate.

Assistiert von: Waqas.

Author
Artikel
#464629

I am trying to: I use a plugin called Soliloquy to build sliders. It allows me to build Dynamic Sliders thanks to their Dynamic Addon. to that that, I need simply need to build a shortcode that would have the following form:
[soliloquy_dynamic id="custom-XXX" images="versteckter Link"]

I'll try to make things simple to explain my situation:
I built a Custom Post Type that I called "Websites" with a Custom Field that is an image that I called "Homepage Screenshot"

I'd like to use the URLs of those Homepage Screenshots to populate the "images" attribute of the Soliloquy Shortcode separated with commas, with no spaces between them.

To do so, I built a View that should output the expected Shortcode populated with the images URLs. Here is what it looks like:


[wpv-layout-start]
	[wpv-items-found]
<!-- wpv-loop-start -->
[soliloquy_dynamic id="custom-XXX" images="
	<wpv-loop>
      [wpv-item index=1]
      [types field='screenshot-homepage' size='full' url='true'][/types]
      [wpv-item index=other]
      ,[types field='screenshot-homepage' output='raw'][/types]
	</wpv-loop>
"]
<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

I visited this URL:

I expected to see the output of this to be something like:


[soliloquy_dynamic id="custom-XX2" images="<em><u>versteckter Link</u></em>"]

Instead, I got:


[soliloquy_dynamic id="custom-XX2" images=" <em><u>versteckter Link</u></em> ,<em><u>versteckter Link</u></em> ,<em><u>versteckter Link</u></em> ,<em><u>versteckter Link</u></em> ,<em><u>versteckter Link</u></em> ,<em><u>versteckter Link</u></em> ,<em><u>versteckter Link</u></em> "]

So I get a bunch of empty spaces before or after each outputted item.

Is there a way to have the same output result but without the added empty spaces that break the Soliloquy Shortcode for Dynamic Sliders?

In Case you are wondering why I'd like to use that Soliloquy plugin to build my slider, the answer is simple, it allows to build simple responsive Sliders with a lot of options that I can't find on Views plugin for now.

If anyone could help me get rid of those empty spaces, it would be really awesome.

#464851

Waqas
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Karachi (GMT+05:00)

Let's try the following code:

[wpv-layout-start]
    [wpv-items-found]
<!-- wpv-loop-start -->
[soliloquy_dynamic id="custom-XXX" images="
    <wpv-loop>
      [wpv-item index=1][types field='screenshot-homepage' size='full' url='true'][/types][wpv-item index=other],[types field='screenshot-homepage' output='raw'][/types]
    </wpv-loop>
"]
<!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
        <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
    [/wpv-no-items-found]
[wpv-layout-end]

After all, these are all short codes in <wpv-loop> and these shouldn't be generating anything out of their boundaries. I hope this way we can eliminate additional spaces caused by the code indentation.

Please let me know if it works for you or not, thanks.

#464949

Hi Waqas, and thank you for your answer.
I totally agree with you, the <wpv-loop> shoudn't be generating anything out of their boundaries, that was what I was expecting. However, it seems that it does generate empty spaces.
I tried with the code you sent me earlier, but it doesn't change anything, it still generates exactly the same output result.
Any other idea?

#464960

Hi again Waqas,

Actually, I followed your idea a little bit further and it fixed my problem, I had to put all the Shortcode construction on the same line. So here is what I did to make my code work:

[wpv-layout-start]
    [wpv-items-found]
<!-- wpv-loop-start -->
[soliloquy_dynamic id="custom-XXX" images="<wpv-loop>[wpv-item index=1][types field='screenshot-homepage' size='full' url='true'][/types][wpv-item index=other],[types field='screenshot-homepage' output='raw'][/types]</wpv-loop>"]
<!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
        <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
    [/wpv-no-items-found]
[wpv-layout-end]

Thank you very much for your help. Now, I am able to dynamically build the shortcode I need. It's going to allow me to go far beyond with wp-toolset.

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.