wordpress insert content before comment_template() - comments

I am trying to inject content into the comment_template() similiar to how you can with comment_form().
For example:
<?php
$args = array("comment_notes_before" => myrp_api_ratings_form_table(null, true));
comment_form($args);
?>
This will make it so what is returned from the myrp_api_ratings_form_table function will appear before the comment form instead of after the submit button.
Is there any way to do something similiar but using the comment_template() function? I tried looking at the codex with no luck. Also, is there any good links to modifying the output of comment_template() any further?
Thank you

There is a lot of actions and filters that is available on the comment_template, you can use them to modify the template, or just build your own template. Here's a list of all the filters and actions available:
http://codex.wordpress.org/Plugin_API/Filter_Reference#Comment.2C_Trackback.2C_and_Ping_Filters
EDIT:
This thou only changes the data of each comment. If you want to change the display, and structure of the real template, I guess you have to create your own template. But it's not as hard as it sounds, there is a great guide in the codex with some nice examples: http://codex.wordpress.org/Function_Reference/wp_list_comments

Related

Drupal 8 - Overwriting a specific view page

I have created a view with several pages. As it is displayed to me with the debug mode, I can also use the view:
views-view-fields--foobar.html.twig
Overwrite With me the whole then looks as follows:
views-view-fields--nd-portfolio-filter.html.twig
Now I would like to overwrite a certain page of my view. I can't find anything suitable in debug mode.
According to https://www.drupal.org/docs/8/theming/twig/twig-template-naming-conventions it should work according to the following pattern:
views-view-fields--foobar--page.html.twig
according to this logic it should look like this with me then as follows:
views-view-fields--nd-portfolio-filter--theaterfotos.html.twig
Unfortunately, that doesn't work. "theaterfotos" is the system name of the page of my view.
Do I have a thought error now? Would be grateful for any help.
Thnx Bavra
As of my understanding of your question you want to apply to the template on a specific page of view.
Your logic is right but I think your name was incorrect it should be in this format
[base template name]--[view machine name]--[view display id].html.twig
on your case, it should be like below because views machine name not using "-"(dash in between) on lowercase and underscores
views-view-fields--nd_portfolio_filter--theaterfotos.html.twig
you should try this and clear the cache of drupal. Hope this will helps you
Thanks

Calling Models in Magento Templates

I am currently working on integrating HTML cuts into Magento's template, however, I am just a little stumped on the structure of Magento itself. I want to list all of the categories inside a custom template in the 'navigation/left'.phtml file. The following accepted answer Magento: Display sub-category list seems to do what I need to do, however,I don't feel comfortable in calling a model inside of a view files as in MVC, which the accepted answer has done.
Is there a better way of putting this in another section of Magento, or perhaps a custom block which extends the Block_Catalog_Product_List class would be a better way of retrieving the categories?
Thanks
The simplest way to do it is to create a module with a helper inside it, that returns the data you need. Then in the template file call this:
$data = Mage::helper('myhelper')->getCategoryList();
//do your magic with $data
There is no point in overriding blocks unless there is no other solution.

Getting article create date joomla

I'm trying to get article's created timestamp or date so I can format it with css. I've searched on google and on the forum but, I'm confused on the result.
I've done this:
echo $this->article->created;
echo $this->item->created;
And is giving me a blank result.
What am I doing wrong?
Looking at the page layout
https://github.com/joomla/joomla-cms/blob/2.5.x/components/com_content/views/article/tmpl/default.php#L114
Line 114 you see how the date is rendered in 2.5.
<dd class="create">
<?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC2'))); ?>
</dd>
So to style it you can just use the create class or you can make a layout override.
This is assuming you want it in an article. If you want it in a list or something look at the appropriate layout for that. And if you want to override the date format itself do that in a layout override.
The element you want seems to vary by version, so make sure whatever you are cribbing off of, matches your installation.
First of All where you are trying to display the created date.
1) In normal article views like default joomla catgory ,blog or any other view.
You should check the following.
The article options that available on the right side options of articles the created date is show true.
Then Also make sure If it assigned to a menu there also these options available there also
make true.
Then you will get the created date in the articles default view.
2)If you are trying with a custom code section you can find some codes like this.
$useDefList = (($params->get('show_author')) OR ($params->get('show_category')) OR ($params->get('show_parent_category'))
OR ($params->get('show_create_date')) OR ($params->get('show_modify_date')) OR ($params->get('show_publish_date'))
OR ($params->get('show_hits')));
on the article default view of joomla.In any version of joomla these should be based on article options values.
Hope this may help you...

magento catalogsearch search for all products (like a view all brands page )

For a project I need to make a kind of view all manufactures page, I am hoping to use catalogsearch but without any parameters. What I mean is the normal catalogsearch is ran and all shoes in all manufacture categories are returned.
The url that is normally passed is testshop.com//catalogsearch/result/index/?manufacturer=2522&q=shoe%20manufactures this works but when I try to pass testshop.com//catalogsearch/result/index/? (or along those lines) this does not work.
I have not started coding this yet as I am not sure where to begin so need a point in the right direction.
I am thinking of just finding the default category id and using this, but not sure if this is the best option to use.
Any advice or help will be great as always. Will post my finished code on here once complete as I think with magento help can be a bit limited.
Cheers
Jason
Maybe try getting the search Model pragmatically
Here is the code to get the Search model:
$search = Mage::getSingleton('catalogsearch/advanced');
To actually search put in the following:
$search = Mage::getSingleton('catalogsearch/advanced')->addFilters(array('name' => $term));
Then to get the results in an object, enter the following line:
$search->getProductCollection();
Hope this helps
I did it. It was a bit of a hack but works perfectly.
I noticed that if you make a search and remove all the filters you are left with a GET request that look something like this /catalogsearch/result/index/?q=Shoe+Brand . But the filters where not showing on the left hand side as a normal catalogsearch would.
So I found the default category id and added this to the GET request. The GET request now looked like this /catalogsearch/result/index/?cat=2&q=Shoe+Brand .
Although the GET request included q=Shoe+Brand it was not actually using this as search criteria.
This was now returning a catalogsearch page with the default category as a filter.
This was showing default category in the filter and breadcrumbs so I had to change the appropriate phtml files to check for this and display 'all brands' instead of 'default category'.
Hope this helps someone else
Jason

CodeIgniter santizing POST values

I have a text area in which I am trying to add youtube embed code and other HTML tags. $this->input->post is converting the <iframe> tags to < and > respectively but not the <h1> and <h2> tags.
Any idea how I can store these values?
If you only have a small number of forms that you need to allow iframes in, I would just write a function to restore the iframe (while validating that it's a valid YouTube embed code).
You can also turn off global_xss_filtering in your config (or not implement it if you're using it), but that's not the ideal solution (turning off all of your security to get one thing to work is generally a horrible idea).
$config['global_xss_filtering'] = FALSE;
To see all of the tags that get filtered out, look in the CI_Input class and search for the '$naughty' variable. You'll see a pipe-delimited list (don't change anything in this class).
Why don't you avoid CIs auto sanitizing and use something like htmlspecialchars($_POST['var']); ? Or make a helper function for sanitizing youtube urls...
Or you could either just ask for the video ID code or parse the code from what you are getting.
This would let you use both the URL or the embed code.
Also storing just the ID takes less space in you database, and you could write a helper function to output the embed code/url.
In this case, use $_POST instead of $this->input->post to get the original text area value, and then use HTML Purifier to clean the contents without losing the <iframe> tag you want.
You will need to check HTML Purifier documentation for details. Please, check this specific documentation page about "Embedding YouTube Videos".

Resources