Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+6 votes
2.2k views
in Plugins by
edited by

Ask with Tags Plugin which I am looking for.It is like asking with a category.When you in a category , q2a /pirske?cat=6  but I want it for tags too.Someone first shared on github but than remove it.

Is there anyone can share it.

Thanks a lot.

Edited;

This plugins is developed by Jair. If anyone need it , just has to change inside qa-ask-with-tags-layer.php  Jair's below code.

https://github.com/neayi/q2a-ask-with-tags-list

Q2A version: 1.8.3
by
I found one but , on tag page does not ask like category page in url
by
what is that plugin? I want to test too?
by
if I cant find a solution , I will use it tag description plugin manually
by
+1
I would use 'tag description' even thou I can make automatic links to  ask with tags.
by
you mean url which you made for asking I guess

1 Answer

+2 votes
by
selected by
 
Best answer

A plugin layer, such as the one you mentioned above, might be useful for that purpose:

  1. Create a plug-in
  2. Create a layer with the following code:
<?php
class qa_html_theme_layer extends qa_html_theme_base {
    public function nav_main_sub()
    {
        if (qa_opt('nav_ask') && qa_user_maximum_permit_error('permit_post_q') != 'level') {
            if ($this->template == 'tag') {
                $tag = qa_request_part(1);
                $this->content['navigation']['main']['ask']['url'] = qa_path_html('ask', array('tags' => $tag ));
            } elseif ($this->template == 'question') {
                // Rebuild 'Ask a Question' link.
                $params = array();

                if (qa_using_categories()) {
                    $categories = qa_db_select_with_pending(qa_db_category_nav_selectspec($this->content['q_view']['raw']['postid'], true, true, true));
                    $categoryids = array_keys(qa_category_path($categories, $this->content['q_view']['raw']['categoryid']));
                    $lastcategoryid = count($categoryids) > 0 ? end($categoryids) : null;

                    if (strlen($lastcategoryid))
                        $params['cat'] = $lastcategoryid;
                }

                if (qa_using_tags() && isset($this->content['q_view']['raw']['tags']))
                    $params['tags'] = $this->content['q_view']['raw']['tags'];

                $this->content['navigation']['main']['ask']['url'] = qa_path_html('ask', !empty($params) ? $params : null);
            }
        }

        parent::nav_main_sub();
    }

    public function form_fields($form, $columns) {
        $tags = qa_html(trim(qa_get('tags')));

        if ($tags && $this->template == 'ask')
            $form['fields']['tags']['value'] = $tags;

        parent::form_fields($form, $columns);
    }
}

It has two features:

  1. When the user is on a tag page, clicking on "Ask a Question" will take the user to the "Ask" page with the tag field pre-filled.
  2. Posts can have a category and/or tags, so when the user is on a post, clicking on "Ask a Question" will take the user to the "Ask" page with both the category and the tag fields pre-filled.

If feature 2 is not needed, then remove the elseif block in the code. It would be like this:

<?php
class qa_html_theme_layer extends qa_html_theme_base {
    public function nav_main_sub()
    {
        if (qa_opt('nav_ask') && qa_user_maximum_permit_error('permit_post_q') != 'level') {
            if ($this->template == 'tag') {
                $tag = qa_request_part(1);
                $this->content['navigation']['main']['ask']['url'] = qa_path_html('ask', array('tags' => $tag ));
            }
        }

        parent::nav_main_sub();
    }

    public function form_fields($form, $columns) {
        $tags = qa_html(trim(qa_get('tags')));

        if ($tags && $this->template == 'ask')
            $form['fields']['tags']['value'] = $tags;

        parent::form_fields($form, $columns);
    }
}

If you don't know how to create a plugin, you might use qa-ask-with-tags-layer.php as a template for the code above.

I hope this answer is helpful. If you have any question, please add a comment below.

If you need specialized Question2Answer services and information you might have a look at the services page or send me a private message.

Have a good day.

by
+1
Done. Please see the updated answer.
by
Works well sir. Many thanks for your efforts.Both options are good.
it makes closer to control  "tag" onq2a more.
My expectation that giving access to people can control/access on own tags.
I think it makes q2a better...
by
+1
That's actually a good idea. You're welcome! My pleasure. :)
by
+1
A least , like category management , we can give a control of tag to someone :)
Generally , giving a access for  category is very restricted , it has to be more access on category.
Also , if q2a can do this for tags than will be perfect.It will take attention of people who cares about brand or etc.They would like to ask for a tag management.It sounds good for me:)
...