简体   繁体   English

在点击功能joomla的文章中添加1个匹配项

[英]Add 1 hit to article on click function joomla

Hi guys i have some trouble here. 嗨,大家好,我在这里有些麻烦。

 <a class="anything" href="another/website">Take me to this product</a>

This button or link over here is added to every article in my joomla site and i have constructed every article to display diffrent products, and the link will take me to the product in my webshop. 此按钮或此处的链接已添加到我的joomla网站上的每篇文章中,并且我已构建了每篇文章来显示不同的产品,并且该链接会将我带到我的网上商店中的产品。

My problem here is i need to have a toplist on my site based on article hits. 我的问题是,我需要根据文章点击数在自己的网站上列出排名。

Basicly i want the link up there to add one hit to the specific article its in onClick 基本上我想在那里的链接向onClick中的特定文章添加一击

You could display articles in a module using: 您可以使用以下方法在模块中显示文章

  • Articles Category Module 文章类别模块
  • Articles - Newsflash Module 文章-Newsflash模块

Both have an option to Order Results by Hits . 两者都可以选择按Hits 结果 排序

To get the url part from module output you have to open module code and add a preg_match() that would search for <a> ... </a> part. 要从模块输出中获取url部分 ,您必须打开模块代码并添加preg_match()来搜索<a> ... </a>部分。

An example would be: 一个例子是:

<?php
    $pattern = "/<a.*?>(.*)<\/a>/";
    preg_match($pattern, $string, $url); // $string would contain module output
    print_r($url);
?>

This tutorial may also help you: Find URLs in Text, Make Links . 本教程还可以为您提供帮助: 查找文本中的URL,创建链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM