Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
4.8k views
in Plugins by
I have a few pages of "custom"
I want to hide the "Sidebar".
But only one of them.
For the page "custom" was the full width.
 
Using the plug-in "Q2AM Hide Sidebar" can hide "sidebar" by selecting "Hide custom".
 
Unfortunately, this hides the "sidebar" in all my pages "custom".
 
In phpMyAdmin, qa_pages table, I saw that each party "custom" has a different ID Number.
 
What changes should I make to files plugin "Q2AM Hide Sidebar", and in a script file Q2A (and has), so I can decide about hiding "sidebar" for each of my page "custom" separately?
Q2A version: 1.61

2 Answers

0 votes
by
edited by

My hack.

You should input relative and comma separated path list in "URL Lists" option. New line is enable too.

e.g.
feedback,
example-plugin-page

qam-sidebar-admin-form.php (L38): add one lines

qa_opt('sidebar_ask', (bool)qa_post_text('sidebar_ask'));
qa_opt('sidebar_urls', qa_post_text('sidebar_urls')); // add  <=== 7/20 add

qam-sidebar-admin-form.php (L132): add lines

// add [start]
array(
  'label' => 'URL Lists',
  'type' => 'textarea',
  'value' => qa_opt('sidebar_urls'),
  'tags' => 'NAME="sidebar_urls" ID="sidebar_urls"',
  'rows' => 10,
),
// add [end]
qam-sidebar-layer.php (L19): add lines
// add [start]
private $hide;
function qa_html_theme_layer($template, $content, $rooturl, $request) {
  qa_html_theme_base::qa_html_theme_base($template, $content, $rooturl, $request);
  $this->hide = false;
  $urls = @qa_opt('sidebar_urls');
  if (isset($urls) && !empty($urls)) {
    $urls = explode(',', str_replace("\n", '', $urls));
    if(in_array(qa_request(),$urls))
      $this->hide = true;
  }
}
// add [end]
qam-sidebar-layer.php (about L50): add one line
(qa_opt('sidebar_ask')) && ($this->template == 'ask')) && (qa_opt('site_theme') === 'Snow')
|| $this->hide // add
qam-sidebar-layer.php (about L67): replace (included bug fix)
/* replace [start]
if(
  !(qa_opt('sidebar_qa')) && ($this->template == 'qa') ||
  !(qa_opt('sidebar_activity')) && ($this->template == 'activity') ||
  !(qa_opt('sidebar_questions')) && ($this->template == 'questions') ||
  !(qa_opt('sidebar_question')) && ($this->template == 'question') ||
  !(qa_opt('sidebar_hot')) && ($this->template == 'hot') ||
  !(qa_opt('sidebar_unanswered')) && ($this->template == 'unanswered') ||
  !(qa_opt('sidebar_tags')) && ($this->template == 'tags') ||
  !(qa_opt('sidebar_categories')) && ($this->template == 'categories') ||
  !(qa_opt('sidebar_users')) && ($this->template == 'users') ||
  !(qa_opt('sidebar_admin')) && ($this->template == 'admin') ||
  !(qa_opt('sidebar_custom')) && ($this->template == 'custom') ||
  !(qa_opt('sidebar_ask')) && ($this->template == 'ask')
)
  qa_html_theme_base::sidepanel();
*/
if(!(
  (qa_opt('sidebar_qa') && ($this->template == 'qa')) ||
  (qa_opt('sidebar_activity') && ($this->template == 'activity')) ||
  (qa_opt('sidebar_questions') && ($this->template == 'questions')) ||
  (qa_opt('sidebar_question') && ($this->template == 'question')) ||
  (qa_opt('sidebar_hot') && ($this->template == 'hot')) ||
  (qa_opt('sidebar_unanswered') && ($this->template == 'unanswered')) ||
  (qa_opt('sidebar_tags') && ($this->template == 'tags')) ||
  (qa_opt('sidebar_categories') && ($this->template == 'categories')) ||
  (qa_opt('sidebar_users') && ($this->template == 'users')) ||
  (qa_opt('sidebar_admin') && ($this->template == 'admin')) ||
  (qa_opt('sidebar_custom') && ($this->template == 'custom')) ||
  (qa_opt('sidebar_ask') && ($this->template == 'ask'))
  || $this->hide // add
))
  qa_html_theme_base::sidepanel();
/* replace [end] */
 
by
Thanks Sama5, to notifying bug.
by
Introduced the changes mentioned to the script. But I do not see an additional line.

You should input relative path and comma separated lists in "URL Lists" option. New line is enable too.
e.g.
feedback,
example-plugin-page

This line should appear in the admin panel, in the options script? Do I need to add the appropriate page in the middle of a script?
Q2A version: 1.61
by
@Sama55 this code doesn't work. I wrote cod with different approaches and works fine. Going to release in a moment. I have fixed the bug you mentioned. Thanks for all your sharing.... Appreciate..
by
Released Hide Sidebar 1.2 http://question2answer.org/qa/25848/q2a-market-hide-sidebar-1-2-released

Thaks to you both sama55 and Jurrek
by
edited by
I got source code from github yesterday. My test environment is Q2A V1.6.1.
@jatin It worked definitely in my environment. Was it what kind of error or phenomenon?
by
I forgot to place one modified point. I'm sorry. I edited answer.
qam-sidebar-admin-form.php (L38): add one lines
by
Welcome
 
Thanks for the fix.
 
I have a question.
 
Is the plugin compatible with 1.2 "custom_home_content"? ("The content to be shown on the home page instead of a list of topics")
 
In the current version (1.2) does not see the possibility of incorporating sidebar on the home page, which was swapped for entry html.
 
In the previous version, the home page (swapped in layout options) acted like side custom.
 
Current Page "custom_home_content" default sidebar is hidden and you can not turn it on.
by
My answer is for V1.1. I don't watch the code of 1.2. If you are satisfied with specifications of 1.1, you restore to 1.1 and may give my hack.
by
@Jurrek,

I have updated the plugin to 1.2 just download and install that. Remember now Custom checkbox has been removed and all custom page should be define in the Custom Pages URL Slug field.
by
Issue has been fixed will update soon
+2 votes
by
Okay I will update this pluign where you can use for custom pages.
...