Osclass Support Forums
Osclass theme support => Sigma Osclass Theme => Topic started by: Aleš Tomažič on January 01, 2023, 11:59:27 AM
-
Hi everyone, I wish to all Happy New Year :P.
Today I found a strange problem on my site. In most of my title tags I have exstra blank space in the end, example:
<title>Description of item - SITE.COM</title>
<title>Category 1 - SITE.COM</title>
Search results are ok:
<title>Search result - SITE.COM</title>
Should i fix my function meta_title() {... ?
Thanks for suggestions.
-
Sorry, could not reproduce anywhere.
-
Sorry, could not reproduce anywhere.
I will create another fresh install and try to reproduce exstra blank space.
-
I done fresh install osclass 8.0.2 from zip and same problem. All titles have exstra space in the end.
-
I managed to get rid of exstra space in categories changing this:
In ../oc-includes/osclass/functions.php
from this:
if ( $b_category && is_array( $category ) && count( $category ) > 0 ) {
$cat = Category::newInstance()->findByPrimaryKey( $category[ 0 ] );
if ( $cat ) {
$result .= $cat[ 's_name' ] . ' ';
}
}
to this:
if ( $b_category && is_array( $category ) && count( $category ) > 0 ) {
$cat = Category::newInstance()->findByPrimaryKey( $category[ 0 ] );
if ( $cat ) {
$result .= $cat[ 's_name' ] . '';
}
}
But I still cant find option, to get rid of exstra space from titles of items.
-
Now is working great, it must be related with citys and regions on install.
If you install new Osclass with Slovenian option you will get blank spaces in titles.
Here is modified code for empty spaces in titles in ../oc-includes/osclass/functions.php:
/**
* @return bool|mixed
* @throws \Exception
*/
function meta_title() {
$location = Rewrite::newInstance()->get_location();
$section = Rewrite::newInstance()->get_section();
$text = '';
switch ( $location ) {
case ( 'item' ):
switch ( $section ) {
case 'item_add':
$text = __( 'Publish a listing' );
break;
case 'item_edit':
$text = __( 'Edit your listing' );
break;
case 'send_friend':
$text = __( 'Send to a friend' ) . ' - ' . osc_item_title();
break;
case 'contact':
$text = __( 'Contact seller' ) . ' - ' . osc_item_title();
break;
default:
$text = osc_item_title() . '' . osc_item_city();
break;
}
break;
case( 'page' ):
$text = osc_static_page_title();
break;
case( 'error' ):
$text = __( 'Error' );
break;
case( 'search' ):
$region = osc_search_region();
$city = osc_search_city();
$pattern = osc_search_pattern();
$category = osc_search_category_id();
$s_page = '';
$i_page = Params::getParam( 'iPage' );
if ( $i_page != '' && $i_page > 1 ) {
$s_page = ' - ' . __( 'page' ) . ' ' . $i_page;
}
$b_show_all = ( $region == '' && $city == '' && $pattern == '' && empty( $category ) );
$b_category = ! empty( $category );
$b_pattern = ( $pattern != '' );
$b_city = ( $city != '' );
$b_region = ( $region != '' );
if ( $b_show_all ) {
$text = __( 'Show all listings' ) . ' - ' . $s_page . osc_page_title();
}
$result = '';
if ( $b_pattern ) {
$result .= $pattern . ' » ';
}
if ( $b_category && is_array( $category ) && count( $category ) > 0 ) {
$cat = Category::newInstance()->findByPrimaryKey( $category[ 0 ] );
if ( $cat ) {
$result .= $cat[ 's_name' ] . '';
}
}
if ( $b_city ) {
$result .= $city . ' » ';
} else if ( $b_region ) {
$result .= $region . ' » ';
}
$result = preg_replace( '|\s?»\s$|' , '' , $result );
if ( $result == '' ) {
$result = __( 'Search results' );
}
$text = '';
if ( osc_get_preference( 'seo_title_keyword' ) != '' ) {
$text .= osc_get_preference( 'seo_title_keyword' ) . ' ';
}
$text .= $result . $s_page;
break;
case( 'login' ):
switch ( $section ) {
case( 'recover' ):
$text = __( 'Recover your password' );
break;
case( 'forgot' ):
$text = __( 'Recover my password' );
break;
default:
$text = __( 'Login' );
}
break;
case( 'register' ):
$text = __( 'Create a new account' );
break;
case( 'user' ):
switch ( $section ) {
case( 'dashboard' ):
$text = __( 'Dashboard' );
break;
case( 'items' ):
$text = __( 'Manage my listings' );
break;
case( 'alerts' ):
$text = __( 'Manage my alerts' );
break;
case( 'profile' ):
$text = __( 'Update my profile' );
break;
case( 'pub_profile' ):
$text = __( 'Public profile' ) . ' - ' . osc_user_name();
break;
case( 'change_email' ):
$text = __( 'Change my email' );
break;
case( 'change_username' ):
$text = __( 'Change my username' );
break;
case( 'change_password' ):
$text = __( 'Change my password' );
break;
}
break;
case( 'contact' ):
$text = __( 'Contact' );
break;
case( 'custom' ):
$text = Rewrite::newInstance()->get_title();
break;
default:
if(trim(Rewrite::newInstance()->get_title()) != '') {
$text = trim(Rewrite::newInstance()->get_title());
} else {
$text = osc_page_title();
}
break;
}
if(!osc_is_home_page()) {
if($text != '' && $text != osc_page_title()) {
$text .= ' - ' . osc_page_title();
} else {
$text = osc_page_title();
}
}
return osc_apply_filter( 'meta_title_filter' , $text );
}
-
I think it's wrong solution.
before "return" in function, place following line:
$text = preg_replace('/\s+/', ' ', $text);
-
I think it's wrong solution.
before "return" in function, place following line:
$text = preg_replace('/\s+/', ' ', $text);
Thank you, better solution it is ???