Skip Navigation

[Resolved] content template for both desktop and mobile

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

Our next available supporter will start replying to tickets in about 6.22 hours from now. Thank you for your understanding.

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 8 replies, has 3 voices.

Last updated by Shane 2 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#2312849

Dear Sir/Madam,

We will develop a mobile app to feed the post content into a webview, we need to remove all menu, header, sidebar and footer. I know how to design a content template but how can I remove the above elements when the post is viewed by mobile? There is 3 possible view to the content, web-base for desktop and responsive for mobile view, if parameter ?webview=1 is passed to the url, then I need to remove all menu, header, sidebar and footer. Should I build one content template for all views or I need to have different content template for different view?

#2313217

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Toolset content templates only replace the content part of the page (concretely, what is output by the core WordPress function the_content in the theme PHP templates). Everything else is generated by the theme, the header, menus, sidebars, footers etc.

So if you want to control the visibility of those then you will need to create custom PHP templates in your theme that modify what is and is not output depending on your webview url parameter.

#2314353

Dear Nigel,

There was a Toolset Layout, I know it is deprecated, is there any replacement?

#2314367

Dear Nigel,

If there is no replacement to the Toolset Layout, how can I use a different content template to same post type but determine the url parameter, below is what I expect to do

hidden link ( use content template A to view the post on desktop )
hidden link ( use content template B to view the post on mobile responsive )
hidden link ( use content template C to view the post in mobile webview )

#2314519

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kelvin,

As Nigel had mentioned this functionality has since been removed/deprecated with our Layouts plugin.

Currently we have mobile/tablet/desktop views available when you're using the Gutenburg editor. What this means is that you're able to customize the display of your single content template to look differently whether it is on desktop , mobile or tablets.

This feature allows you to hide the elements that you don't want to be seen on the various screen sizes.

how can I use a different content template to same post type but determine the url parameter, below is what I expect to do

If you're familiar with coding then you can make use of the function below to achieve this.
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

However I do recommend that you use the features that the Gutenburg editor offers in terms of hiding/displaying different elements per your display screen.

Thanks,
Shane

#2317899
Screenshot 2022-03-15 at 10.43.56 PM.png
Screenshot 2022-03-15 at 10.43.27 PM.png

Dear Shane,

A custom post type can only assign to one content template usage, how can I change the content template for different view and determine the url parameter? Once I view the custom post, the Toolset will apply the corresponding content template, there is no way for me to select which content template to be used if different url parameter.

Refer to the screenshot, I use the Gutenburg editor but there is no mobile/tablet/desktop views available from the content template setting. Please advise how with some screenshot.

#2318627

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kelvin,

A custom post type can only assign to one content template usage, how can I change the content template for different view and determine the url parameter?

As mentioned previously this will need to be done using PHP. If you're familiar with writing PHP code then you can make use of the function below to dynamically assign your post to a content template based on the URL value when the post is being viewed.
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

The render_view_template function can dynamically assign a content template to your post when it is being viewed.

I use the Gutenburg editor but there is no mobile/tablet/desktop views available from the content template setting. Please advise how with some screenshot.

The content template itself won't be able to be change when viewed on the different devices however you can disable various toolset elements.

If you click on a Block on your template and scrolled to the Advanced tab, you should see the text "Hide element" from there you can select which device you want this element to be hidden on.

Apart from this there is not much else that can be done.

Thanks,
Shane

#2321465

Dear Shane,

Got your answer, may I know how it determine the device is mobile, tablet or desktop? Is it checked by browser agent or viewpoint?

#2323017

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Kelvin,

may I know how it determine the device is mobile, tablet or desktop? Is it checked by browser agent or viewpoint?

For this setting I believe it is done using CSS. Where the display size is checked to determine if this section should be hidden or not.

Thanks,
Shane