Skip Navigation

[Resolved] Problem with shortcode toolset

This support ticket is created 2 years, 4 months ago. 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.

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

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

This topic contains 11 replies, has 2 voices.

Last updated by Waqar 2 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#2425859

Until the last update I used these lines of code in my code, but now it doesn't work anymore, it can't extract the list of documents I need, but it generates an error in the pages where I use it.

This is the code:
<div class="box-documenti">
<h1> <?php echo __('Documenti Allegati', 'theme-text-domain') ?></h1>
<div class="box-documenti-wrapper">
<?php echo wpv_do_shortcode('[wpv-form-view name="lista-osservatorio"]'); ?>
<p></p>
<?php echo wpv_do_shortcode('[wpv-view name="lista-osservatorio" view_display="layout" order="desc"]'); ?>
<div style="clear:both"></div>
</div>
</div>

This is one of the pages: hidden link
The page also makes a mistake in the layout because the page is not full-width and then fails to display the list of documents. Why doesn't this piece of code work anymore?

#2425985

Hi,

Thank you for contacting us and I'd be happy to assist.

An error like this can be encountered if Toolset Views or Blocks plugin is not active. Can you please make sure that one of these two plugins is active on the website?

In case the issue persists, you're welcome to share temporary admin login details, for further troubleshooting.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2426411

Thank you for sharing the admin access.

The "Toolset Types" plugin is active on the website, but the code that you mentioned is calling a view, which is a feature included in the "Toolset Blocks" or "Toolset Views" plugins.

This means that for that code to work properly, you'll have to activate one of those plugins on the website, too.

Please go to WP Admin -> Plugin -> Aggiungi nuovo -> Commerciale and install and activate the "Toolset Blocks" plugin.
( screenshot: hidden link )

Note: After activating the plugin please also make sure to select the option "Show both the legacy and Blocks interface and let me choose which to use for each item I build" for the "Editing experience" setting at WP Admin -> Toolset -> Settings -> General.

#2426861

Thanks for the support, now there are no errors and the documents are visible.

I have to solve a display problem though. I use WPML and practically the shortcode makes me see the linked documents in all languages (Italian and English) I would need to view only the documents in Italian for the Italian page and only the documents in English for the English page, how do I set up by default the language filter based on the page where I am?
As you can see I have inserted a select "Document language" that allows me to filter documents, you can select the option automatically based on the language.

Currently as soon as I open the page for example hidden link
I view all the documents both Italian and English.
Which method do you recommend?
Thank you

#2427037

Thanks for the update and glad that it worked.

WPML automatically filters the view's results based on the current language, but, most likely it is not working in this case because this code is being called in directly in a PHP template file.

I'll recommend creating a new content template and then including your code in that:


<div class="box-documenti">
	<h1>Documenti Allegati</h1>
	<div class="box-documenti-wrapper">
		[wpv-form-view name="lista-osservatorio"]
		<p></p>
		[wpv-view name="lista-osservatorio" view_display="layout" order="desc"]
		<div style="clear:both"></div>
	</div>
</div>

Next, you can load this new content template in your template file's PHP code, using the "wpv-post-body" shortcode:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body )


<?php echo do_shortcode('[wpv-post-body view_template="Name of the template"]'); ?>

Note: You'll replace "Name of the template" with the actual name/title of your content template.

When the code and views will be loaded through a content template, the necessary WPML filters should be applied to show the results based on the current language.

#2427461

Hi Waqar and thanks.

I added a new Content Templates but now I can't edit the templates because when I click on "edit" of any content templates the server generates an Error 503 ... it didn't happen before.
How can I solve?

After solving this problem, regarding your previous explanation I would like to ask you some things:

1) How do I add the code, with what kind of block? In a text field? What type of Block should I use to enter the code? I have to copy exactly the code I put in the php file? Like this:
<div class = "box-documents">
<h1> Attached Documents </h1>
<div class = "box-documents-wrapper">
[wpv-form-view name = "list-observatory"]
<p> </p>
[wpv-view name = "observatory-list" view_display = "layout" order = "desc"]
<div style = "clear: both"> </div>
</div>
</div>

2) Currently, if you see "lista-doc-osservatorio" I had put two selects, should I delete those?

3) I need to understand better how to build this template and what to change compared to the one before. I duplicated the "lista-doc-osservatorio" template which is the old one and I gave the new template the name " Lista documenti Osservatorio". What do i need to change? Delete the select? And then?

4) Should I also create a View? Or is there no need?

Thank you

#2427809

Thanks for writing back.

I tried to access your website, but it seems to timeout without any response. Have you enabled any proxy or Geo IP restriction on the server?

To troubleshoot the error 503, I'll recommend turning on WordPress debugging and then checking the server's error logs for any errors or warnings.
( ref: https://wordpress.org/support/article/debugging-in-wordpress/ )

In case, there is no error or warning in the logs, you're welcome to share a clone/snapshot of the website, for further troubleshooting.
( ref: https://toolset.com/faq/provide-supporters-copy-site/ )

Note: I've set your next reply as private again.

As for your specific questions:

1). This code is a combination of HTML and Toolset shortcodes and can be used in the Toolset's "Fields and Text" block, or WordPress' standard "Classic" block or "Custom HTML" block.
( When Toolset's shortcodes are involved, I'll recommend using the "Fields and Text" block over others. And make sure that the "HTML" tab is selected and not the "Visual" tab )

Please note that the code in your first reply included the PHP code too because it was being used in the PHP template file. But the code in my last reply doesn't have PHP code and is using simple HTML and shortcodes.

2). I can't see the page at the moment, but, if the select field is for the language filter, you won't need it once correct language results are automatically showing.

3). One big advantage of using Toolset plugins is that you can assign a content template to your post types so that you can make the changes to the whole template right from the admin area, without having to edit the PHP template files.

Here is a useful guide on the topic:
https://toolset.com/lesson-placement/lesson-placements-1621067-1621091/

Please let me know if you have any questions about using the content templates.

4). If you have already created a view to show the list of documents, you don't have to create a new one.

#2428961

Thanks for the update.

I can now access the website's admin area. I can open the edit screen for the content template "test-osservatorio" but not for the "Lista documenti Osservatorio" and "lista-doc-osservatorio" and it shows the error 503.

Did you check the server's error log and do I have your permission to download the clone/snapshot of the website?

#2429159

Hello,
honestly I don't know if I'm checking in the right place, I opened Cpanel and on Errors it gives me this error alone:
"2022-08-02 00: 10: 57.537252 [INFO] [57061] [T0] [151.37.130.122:55675-H3:1262FE3173FC8637-1372#APVH_eurispes.eu:443] File not found [/ home / gxyoygad / public_html / 503 .shtml]"
It doesn't seem to me that it gives me information about the 503 error. I don't know how to fix it ... on the "test-osservatorio" template it doesn't give the same error, so there is some problem with the other templates, after I made the last changes he hasn't opened them anymore.

For the clone of the site I don't know what to do?

#2429175

Hello Waqar,
I managed to solve the 503 error, now if you log in you can see the "lista-osservatorio" in the View, but I can't understand why I entered the selections and they don't work, that is, if you look at the select "Go to page" it doesn't it gives me the number of correct pages for examples in this page hidden link... and then the documents are both in Italian and in English ... maybe because they don't fit as they were loaded?

#2429503

Hi Waqar,
I was able to go ahead if you go to this page: hidden link

the remaining problems are:

1) I inserted a filter with select that filters posts based on a custom field "Document year" but this filter is not visible, if I view the code with chrome inspector I see the form but there is a display: none and I don't understand why

2) I have to view the documents based on another custom field called "Document language", when this field is equal to the string "Italian" I have to insert the documents in the page with Italian language, when it is equal to the string "English" I have to view the documents on the page in English. As if there was an automatic filter based on the language of the page linked to the "document language" field ... can it be done?

3) I would like to insert only the "Post title" in the document loop and then clicking on the title I have to open the pdf ... currently you can see both the title and the url of the pdf. How can I do?

I deleted the unused views and templates
Thank you

New threads created by Waqar and linked to this one are listed below:

https://toolset.com/forums/topic/split-view-not-working-as-expected/

#2430301

Thanks for the update and glad that the 503 error is fixed now.

I've created a new ticket for your questions related to the view's settings and will follow up on it, shortly.
( ref: https://toolset.com/forums/topic/split-view-not-working-as-expected/ )

You're welcome to mark this ticket as resolved and start a new one for each new question and concern.