Kunena for Joomla uses nofollow for internal links - php

For some reason Kunena puts nofollow links for everything internal. This makes sense for all external links but certainly not for internal ones. I want Google to index the paths associated with the forum posts I have.
I'm hoping someone knows how to remove the nofollow links. It looks like this file is the main one: components/com_kunena/lib/kunena.link.class.php
There are a few functions where I remove the nofollow links such as:
static function GetHrefLink($link, $name, $title = '', $rel = 'nofollow', $class = '', $anker = '', $attr = '') {
return '<a ' . ($class ? 'class="' . $class . '" ' : '') . 'href="' . $link . ($anker ? ('#' . $anker) : '') . '" title="' . $title . '"' . ($rel ? ' rel="' . $rel . '"' : '') . ($attr ? ' ' . $attr : '') . '>' . $name . '</a>';
}
//
// Basic universal href link
//
static function GetSefHrefLink($link, $name, $title = '', $rel = 'nofollow', $class = '', $anker = '', $attr = '') {
$uri = $link instanceof JURI ? $link : JURI::getInstance($link);
if ($anker) $uri->setFragment($anker);
return JHTML::_('kunenaforum.link', $uri, $name, $title, $class, $rel, $attr);
}
I've tried removing the parameter everywhere, I tried just leaving it empty and I've tried using follow as a replacement. I've also tried looking for every single place where nofollow is shown in the whole Kunena component and tried removing those. Still no luck. Anyone with any ideas?
Kunena: 2.0.2
Joomla: 2.5.7

You dont need to change nofollow because google will index whole topic and categories. Check url for topic if its indexed. And add RSS and sitemap to google webmaster. You can configure RSS# kunena settings

Resolved this by changing this file: administrator/components/com_kunena/libraries/view.php
Find:
public function getTopicLink
Change this line:
return JHTML::_('kunenaforum.link', $uri, $content, $title, $class, 'nofollow');
to:
return JHTML::_('kunenaforum.link', $uri, $content, $title, $class, 'follow');
This exists in several spots.

If I understand your original concern, you want to remove all the rel="nofollow" references.
I would do this with a free component called ReReplacer. http://www.nonumber.nl/extensions/rereplacer
Create a rereplacer item that searches for rel="nofollow" and replaces it with rel="follow".
I did this for a forum of Joomla users that we want them to have follow links in their signatures.
If you buy the pro version of rereplacer then you can specify the replacement for only Kunena.

Related

Add deep links to flipkart affiliate link

I am trying to create a affiliate link geenrator using php. I need help to create a flipkart deep affiliate link,which can remove 'www.' and add 'dl.' if present or add 'dl.' before link. For example if input link was https://www.flipkart.com/?affid=xyz then it sends me https://dl.flipkart.com/dl/?affid=xyz . Same for the below links :-
Input link ---> Output Link
https://flipkart.com/?affid=xyz --> https://dl.flipkart.com/dl/?affid=xyz , or
https://dl.flipkart.com/?affid=xyz --> https://dl.flipkart.com/dl/?affid=xyz , or
https://dl.flipkart.com/?affid=xyz --> https://dl.flipkart.com/dl/?affid=xyz
Thanks in advance.
Use parse_url() to get the url metadata. Now, check for host and just overwrite it with dl.flipkart.com and so goes for the path as well.
Snippet:
<?php
$tests = [
'https://www.flipkart.com/?affid=xyz',
'https://flipkart.com/dl?affid=xyz',
'https://dl.flipkart.com/?affid=xyz',
'https://dl.flipkart.com/?affid=xyz',
'https://dl.flipkart.com/dl?affid=xyz',
'https://flipkart.com/whirlpool-1-5-ton-5-star-split-inverter-ac-white/p/itmf8fb8a675505d?pid=ACNFE6K2BXFY6EKX'
];
foreach($tests as $test){
echo $test," => ",getNewURL($test),PHP_EOL;
}
function getNewURL($url){
$url_parts = parse_url($url);
$url_parts['host'] = 'dl.flipkart.com';
$url_parts['path'] .= "/";
if(strpos($url_parts['path'],"/dl/") !== 0) $url_parts['path'] = '/dl/'.trim($url_parts['path'],"/");
return $url_parts['scheme'] . "://" . $url_parts['host'] . $url_parts['path'] . (empty($url_parts['query']) ? '' : '?' . $url_parts['query']);
}

Modifing generated links from url library in opencart

First lemme tell you what i am trying to achieve here . Suppose there is a url like this http://www.example.com/?id=12345 now what i want is if there is an id parameter available in the url i want to append the same parameter to every url on that page . Opencart has a url library that generates url i am sure you all must be familiar with it too , i found a way to do what i want but it's working at just some random parts of the website like categories url's are generating with id parameter appended to it and other's dont .
here's what i tried so far
File : System/libray/url.php
here's the function
public function link($route, $args = '', $connection = 'NONSSL') {
if ($connection == 'NONSSL') {
$url = $this->url;
}else {
$url = $this->ssl;
}
$url .= 'index.php?route=' . $route;
if ($args) {
$url .= str_replace('&', '&', '&' . ltrim($args, '&'));
}
foreach ($this->rewrite as $rewrite) {
$url = $rewrite->rewrite($url);
}
if(isset($_GET['id']))
{
if(!empty($this->request->get['id']))
$url .= '&id='.$this->request->get['id'];
if(!empty($_GET['id']))
{
$url .= '&id='.$_GET['id'];
}
}
return $url;
}
The problem is that not everything uses this method to generate its URLs.
For example, anything to do with banners (e.g. the Carousel module) uses links that the admin sets manually in System->Design->Banners, so you would also need to edit the code for this too. The simplest and probably the correct way is to edit the data that the models spit out e.g.
model_design_banner->getBanner() becomes
public function getBanner($banner_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner_image bi LEFT JOIN " . DB_PREFIX . "banner_image_description bid ON (bi.banner_image_id = bid.banner_image_id) WHERE bi.banner_id = '" . (int)$banner_id . "' AND bid.language_id = '" . (int)$this->config->get('config_language_id') . "'");
if (isset($_GET['id'])) {
array_walk($query->rows, function(&$value) {
$value['link'] .= '&id=' . $_GET['id'];
});
}
return $query->rows;
}
It's either that, or edit the output in every single controller that uses this method.
That's just an example for banners, though. I don't recall off-hand which other modules will need to be edited, but if there's a particular one that's making you scratch your head, let me know and I'll give you another example to fix it.

Get English page title Joomla

I'm working with an custom back-end template in Joomla and now I'm come to a point that I need to support multiple languages.
In the begin of the development I did not think about multiple languages and that gives me some trouble now. That it is best to rewrite the code and make it "smarter" I know, but at this point there is not much time to rewrite this code.
In the backend I'm working with icons that are based on the page title. For example the page Article Manager requests the icon images/icon/article-manager.png. So you see what happens if the page title is for example German and is called Inhalt.
At this moment I use this code to generate the iconpath:
#Loading Joomla Document Module
$doc = JFactory::getDocument();
#Get the page title
$title = explode("-", $doc->title);
$title = trim(end($title));
#Generate icon path
$lastTitle = explode("-", $title);
if (strpos(end($lastTitle), ':')) {
$lastTitle = explode(":", end($lastTitle));
$lastTitle = $lastTitle[0];
$iconPath = trim($lastTitle);
$iconPath = 'templates/' . $this->template . '/images/icons/' . strtolower(str_replace(" ", "-", $iconPath)) . '.png';
} else {
$iconPath = trim(end($lastTitle));
$iconPath = 'templates/' . $this->template . '/images/icons/' . strtolower(str_replace(" ", "-", $iconPath)) . '.png';
}
Now I'm thinking of searching the database for the page/componetent/modul/plugin ID but is there a faster/easier way to edit it?
Work around
As earlier stated, icons generated by a page title is indeed a bad idea. But Lodder came with a pretty nice and easy work around. So I decided to follow his idea. I added an extra variable that checks if it is a 'subpage', when yes then it extends the icon file name with this subpage.
#Loading Joomla Application Module
$app = JFactory::getApplication();
#Genrate page icon
$comp = $app->input->get('option');
$view = $app->input->get('view');
if(!empty($view)) {
$iconFileName = $comp . '-' . $view;
} else {
$iconFileName = $comp;
}
$iconPath = 'templates/' . $this->template . '/images/icons/' . $iconFileName . '.png';
Basing the icons on the Page Title is a bad idea. Purely because as you have already mentioned, your site is multi-lingual, therefore different languages will result in different results.
I would personally base the icons on the component name. For example:
$jinput = JFactory::getApplication()->input;
$view = $jinput->get('option');
The above code will output com_content and will always be the same for all languages.
You can then simply name your icon com_content.png and call the icons like so:
$iconPath = 'templates/' . $this->template . '/images/icons/' . $view . '.png';
Hope this helps

Joomla 2.5 jroute trouble with localhost

I wrote a component and i have trouble using jroute for building links
Example : In my default tmpl in admin part,
if use $link = ''.JRoute::_( 'index.php?option=' . $option . '&task=tournoi.edit&id=' . $row->tournois_id );
or
$link = JRoute::_( 'index.php?option=' . $option . '&task=tournoi.edit&id=' . $row->tournois_id );
i get
http://joomla_new/administrator/index.php?option=com_tournois&task=generatereport&tid=1" where localhost is missing.
if i just add space like this : $link = ' '.JRoute::_( 'index.php?option=' . $option . '&task=tournoi.edit&id=' . $row->tournois_id );
i get
http://localhost/%20/Joomla_new/administrator/index.php?option=com_tournois&task=tournoi.edit&id=1
Anyone has an idea ?
Thanks !

buddy press profile link not going to correct place

I created a bp-custom.php and regrouped the menu items fine. But now i am trying to add a link to go to /site/members. It list all the members.
When i add it though it goes under the profile I am viewing. I am redirecting to a wordpress page if that helps. Or is there a better way to do this.
Ex :
http://website.com/log-in/members/username/members/
I want it to go just here
http://website.com/log-in/members/
I would love to learn how to just put a url and no slug but whatever works. I do not know why it keeps referencing that signed in /member/username. I have even tried parent url and that did not work. I might have been using parent url syntax wrong.
Here is the function
function mb_bp_profile_menu_posts() {
global $bp;
bp_core_new_nav_item(
array(
'name' => 'Members',
'slug' => 'members',
'position' => 60,
)
);
}
I know that i can create .htaccess for this. But I don't want to do it.
May i know what is the clean way (alternate way) to do this?
I have tried what the user said in comment below and found in bp-members-template this function. I then added the part in bold to add the link but that did not work. I am just adding a google link for testing only.
function bp_get_displayed_user_nav() {
global $bp;
foreach ( (array) $bp->bp_nav as $user_nav_item ) {
if ( empty( $user_nav_item['show_for_displayed_user'] ) && !bp_is_my_profile() )
continue;
$selected = '';
if ( bp_is_current_component( $user_nav_item['slug'] ) ) {
$selected = ' class="current selected"';
}
if ( bp_loggedin_user_domain() ) {
$link = str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $user_nav_item['link'] );
} else {
$link = trailingslashit( bp_displayed_user_domain() . $user_nav_item['link'] );
}
echo apply_filters_ref_array( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], array( '<li id="' . $user_nav_item['css_id'] . '-personal-li" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item ) );
**echo "<a href='http://www.google.com'>Google</a>"; }**
}
The bp_core_new_nav_item function is used to add a link to the user's navigation which explains why you're seeing URLs like /members/username/members/ when clicking on the tab. I don't think bp_core_new_nav_item is the right approach here.
An alternative approach would be to replace the function in your theme template that outputs the navigation with your own custom menu.
See this article on the BP Template Hierarchy which shows you how you can set up your own templates:
http://codex.buddypress.org/themes/theme-compatibility-1-7/template-hierarchy/

Categories