![]() |
How to show php widget in article pages only?
Hi
I tried to display a PHP widget in article preview page and hide it from the layout in the section page, but I failed until now :( So, any body can help me in this? and how can I pass variables to this widget? like parent section id, author name and author id for example? Another question, how I can show any other widget like "last articles" widget in the article page only and hide it from the section page or show it in section page and hide it in the article preview page? what a specific condition I must add to the template? Thanks in advance. |
Please help !!
|
Quote:
|
Thank you for your reply
I tried in the first step to add condition to the widget template (I just use the default php eval widget to understand things), but I didn't figure out what is the condition that I must use in template to say this page is section or article !! Then I tried to make plugin to bypass variables and stuck there too, I don't know even to let the plugin know which nodeid he is in !! So by simple words, could you please help me in make widgets appear in article page of some sections (not all article pages) and hide them from their parent sections? To be more specific, I want to add this php widgets, 1- the last articles from the same author and show it in the articles in opinion section articles only, and of curse it doesn't make sense to show it in the section page it self, so I need to bypass author information to the widget to make the query. 2- the related articles to this article, I already add them as special field in the DB when add/edit articles, so I need to by pass these fields too (It stored in cms_node table) 3- the last articles from this section, so I want to use the default recent article widget but need a condition to prevent it from appearing in the section page. And of curse I need to bypass the issection value to the widget to display the widget of hide it. I wish I made things clear to you now :). Thanks in advance. --------------- Added [DATE]1390979373[/DATE] at [TIME]1390979373[/TIME] --------------- I forget the forth widget that I want, I want to add the most popular articles widget (the code of it is here in vb.org) but want to show it for the current section not for the whole site, so I need to bypass sectionid to it to modify the query. Thanks. |
If you show your code, I will try to assist you in what you are working on, but only one step at a time. So I only need to know what your current programming question is and how I can exactly help you. I am replying to your request for help because you seem adept enough to handle this. If you need someone to do this for you please submit your inquiry to the unpaid/paid request forums.
Quote:
Have you successfully cloned a widget by using a new template? This is where you would add the additional template conditionals and variables you require -- of course they would have to be available from the PHP code. |
Hi again and thanks for your caring :)
Actually I can't give you all attempts that I made because they are a lot (I was trying for 3 days without any luck). But here is the main things that I did 1- I duplicated the template that used by php eval widgets and name it the same name with "test" at the end. 2- I checked the cms_node table and find that the main fields that I must concentrate on are nodeid and issection. 3- I tried to add set of conditions to the template that I made without any luck. 4- I find the way to get the nodeid in the widget and print it in the widget it self and this is very big step but the problem that I faced here is the cache problem, the same nodeid printed in the widget in any section or article, so this make me crazy and if I make the full code to show what I want it will not updated in time !! here is the code of the widget PHP Code:
Then for the template it self to display the widget or hide it I tried to make a plugin using this code PHP Code:
and in the widget template I add a condition regarding the valuse of this code HTML Code:
{vb:raw issection}<br>{vb:raw mynodeid} So please help me in this tow things: 1- disable the cache for this widget. 2- make the right condition using the plugin or any better way to can control when I want to show the widget and when I want to hide it. At the end, this is something like case study and I think many users will get benefit of this if we can implement it, and you can imagine how many things you can do with php widgets if you get the power points of them. Thanks in advance. --------------- Added [DATE]1391049060[/DATE] at [TIME]1391049060[/TIME] --------------- Another point, I want a way to control the cache time for php evaluation widgets, because I think in some widgets that are fixed in their section and don't need to refresh with every page load. |
Thanks for posting in detail, I will get bck to you after I review all this... :)
|
Thank you, and your effort very appreciated.
|
Quote:
You really don't need to directly query the database again for on-page content. 1. Caching is done in vBCms_Widget_ExecPhp::getPageView() between lines 174 & 175. For testing, I added the NodeId to the hash to make the cache unique to the current node...you can just comment out the reading of the cache on 175 if you want to. This was my code in line 174 for testing: PHP Code:
2. Again, you'll have to directly modify the widget's code. Around line 173, add the following line: PHP Code:
My sample widget code: PHP Code:
PHP Code:
|
Thank you Dead Eddie for your help, I will make my tests and let you know.
But what about the default widgets like "recent articles widget"? could we make them show and hide as we want? Now I just have one question, Is the cashing now working for every individual node? not for every widget? if this is write, is this will make any bad impact on the system performance (too many cashing, a lot of memory space to save them)? Thanks :). --------------- Added [DATE]1391138658[/DATE] at [TIME]1391138658[/TIME] --------------- Hi Dead Eddie again I think with this implementation we will may face some problems regarding other PHP eval exec widgets that didn't need to refresh every time, specially when we talking about high traffic board and CMS, so is there a way to keep caching for other widgets, I mean is there a way to deal with caching time like what other default widgets have and put the value to 0 for widgets that display unique value for every page and make it 30 minutes for example for widgets that display the same thing in all pages? Thanks in advance. --------------- Added [DATE]1391139712[/DATE] at [TIME]1391139712[/TIME] --------------- How stupid I'm :) I just put 0 in the caching time for this widget and it works fine :) |
All times are GMT. The time now is 01:12 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|