-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Hi,
In testing pagespeed insights is complaining:
pagespeed is also complaining:
Links are not crawlable
Search engines may use href attributes on links to crawl websites. Ensure that the href attribute of anchor elements links to an appropriate destination, so more pages of the site can be discovered. Learn how to make links crawlable
Uncrawlable Link
div.slideout-body > div#j2store-search-274 > form#j2storeserachForm_274 > a.btn
div.slideout-body > div#j2store-search-274 > form#j2storeserachForm_274 > a.btn
This references the default.php file in the search module:
<?php
# mod_j2store_search - J2Store Search
// no direct access
defined( 'JEXEC' ) or die( 'Restricted access' );
$url = JRoute::('index.php?option=com_j2store&view=products&task=browse&Itemid='.$mitemid);
?>
<div id="j2store-search-<?php echo $module->id;?>" class="j2store-search-product <?php echo $moduleclasssfx;?>" >
<form action="<?php echo $url;?>" method="" class="form-horizontal" name="j2storeserachForm" id="j2storeserachForm<?php echo $module->id;?>" >
<?php if ($params->get('show_label', 1) == 1): ?>
<label for="mod_j2storesearch"><?php echo JText::('J2STORE_SEARCH'); ?></label>
<?php endif; ?>
<input type="text" class="inputbox" name="search" id="mod_j2storesearch-<?php echo $module->id; ;?>" value="<?php echo $search;?>" placeholder="<?php echo JText::('J2STORE_FILTERSEARCH'); ?>"/>
<a class="btn btn-primary" onclick="jQuery('#j2storeserachForm<?php echo $module->id;?>').submit();">
<i class="icon-search"></i>
</a>
<?php foreach ($categoryList as $key=>$cat):?>
<input type="hidden" name="catid[<?php echo $key;?>]" value="<?php echo $cat;?>" />
<?php endforeach;?>
</form>
</div>
I changed it to:
<?php
# mod_j2store_search - J2Store Search
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
$url = JRoute::_('index.php?option=com_j2store&view=products&task=browse&Itemid='.$mitemid);
?>
<div id="j2store-search-<?php echo $module->id;?>" class="j2store-search-product <?php echo $moduleclass_sfx;?>" >
<form action="<?php echo $url;?>" method="get" class="form-horizontal" name="j2storeserachForm" id="j2storeserachForm_<?php echo $module->id;?>" >
<?php if ($params->get('show_label', 1) == 1): ?>
<label for="mod_j2store_search-<?php echo $module->id; ?>"><?php echo JText::_('J2STORE_SEARCH'); ?></label>
<?php endif; ?>
<input type="text" class="inputbox" name="search" id="mod_j2store_search-<?php echo $module->id; ?>" value="<?php echo $search;?>" placeholder="<?php echo JText::_('J2STORE_FILTER_SEARCH'); ?>"/>
<button type="submit" class="btn btn-primary" aria-label="<?php echo JText::_('J2STORE_SEARCH'); ?>">
<i class="icon-search" aria-hidden="true"></i>
</button>
<?php foreach ($categoryList as $key=>$cat):?>
<input type="hidden" name="catid[<?php echo $key;?>]" value="<?php echo $cat;?>" />
<?php endforeach;?>
</form>
</div>
Changes made:
Line 16: Changed method="" to method="get" (proper form method)
Line 18: Fixed the label's for attribute to match the input ID (removed extra semicolon)
Line 20: Removed extra semicolon from input ID
Lines 21-23: Replaced the tag with a proper element
Line 21: Added aria-label for accessibility
Line 22: Added aria-hidden="true" to the icon so screen readers ignore the decorative element
This fix:
Resolves the PageSpeed crawlability warning (buttons don't need href attributes)
Uses semantically correct HTML (submit button instead of link with onclick)
Adds proper accessibility labels
Maintains all existing functionality
I also notice the file still references old J3 legacy code which will need to be fixed for v6