Jump to content

[Resolved] need help getting shop/index.php only


Millie Moore

Recommended Posts

The following is the code I have with the if statement that was given to me and I thought it was to work on only my store's index.php page, but with it in my main.php file and I check both shop/ and shop/index.php, it all shows up on both pages.  I want the title and meta tag to show up only on shop/index.php.  Is there such a way?

{if $SECTION_NAME eq "home"}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Millie, Larry Store</title>
<meta name="description" content="Welcome to the store on Motorhead69. We sell a variety of items from household furnishings to home furniture.">
</head>
</html>
{/if}
 

Please help if you can.  I have CCv6.0.11.

Thanks

Millie Moore

 

Link to comment
Share on other sites

Let's start with re-organizing the HTML in the <head> section.

The main.php template, lines 15-36, approximately.
   <head>
     <title>{$META_TITLE}</title>
     --- Stuff we are not interested in. ---
     <meta name="description" content="{if isset($META_DESCRIPTION)}{$META_DESCRIPTION}{/if}">

Move the meta description up to be below the title:
   <head>
     <title>{$META_TITLE}</title>
     <meta name="description" content="{if isset($META_DESCRIPTION)}{$META_DESCRIPTION}{/if}">
     --- Stuff we are not interested in. ---

This makes it easier to keep or kill both these two lines with one test.

We will test if the SERVER_URI contains index.php in it.

   <head>
{if $smarty.server.REQUEST_URI|stristr:'index.php'}
      <title>{$META_TITLE}</title>
      <meta name="description" content="{if isset($META_DESCRIPTION)}{$META_DESCRIPTION}{/if}">
{/if}

This tests if the SERVER_URI string actually contains 'index.php'. If it does, then the title and description is kept. If not, the title and description gets killed.

Link to comment
Share on other sites

1 hour ago, bsmither said:

Let's start with re-organizing the HTML in the <head> section.


The main.php template, lines 15-36, approximately.
   <head>
     <title>{$META_TITLE}</title>
     --- Stuff we are not interested in. ---
     <meta name="description" content="{if isset($META_DESCRIPTION)}{$META_DESCRIPTION}{/if}">

Move the meta description up to be below the title:
   <head>
     <title>{$META_TITLE}</title>
     <meta name="description" content="{if isset($META_DESCRIPTION)}{$META_DESCRIPTION}{/if}">
     --- Stuff we are not interested in. ---

This makes it easier to keep or kill both these two lines with one test.

We will test if the SERVER_URI contains index.php in it.


   <head>
{if $smarty.server.REQUEST_URI|stristr:'index.php'}
      <title>{$META_TITLE}</title>
      <meta name="description" content="{if isset($META_DESCRIPTION)}{$META_DESCRIPTION}{/if}">
{/if}

This tests if the SERVER_URI string actually contains 'index.php'. If it does, then the title and description is kept. If not, the title and description gets killed.

I tried the following and it didn't work.

{if $smarty.server.REQUEST_URI|stristr:'index.php'}

Before I saw this and did trial and error from what you told me, bsmither, this following worked but I don't know if it's supposed to work.

{if {$smarty.server.REQUEST_URI} eq "/shop/index.php"}

 

Link to comment
Share on other sites

There is something we always need to keep in mind - Smarty caches rendered copies of templates. Sometimes, after making a change to a template, Smarty doesn't notice this and still uses the cached copy.

So, while we are making edits to the templates, we should have the cache function switched off. In admin, Store Settings, Advanced tab, Disable Caching.

Then have the browser show you the HTML source.

Link to comment
Share on other sites

10 hours ago, bsmither said:

There is something we always need to keep in mind - Smarty caches rendered copies of templates. Sometimes, after making a change to a template, Smarty doesn't notice this and still uses the cached copy.

So, while we are making edits to the templates, we should have the cache function switched off. In admin, Store Settings, Advanced tab, Disable Caching.

Then have the browser show you the HTML source.

OK I did that and now I'm finding 'index.php' and 'index.php?_a=recover' now pull the same info.  Those two obviously need to be different.  How would I go about fixing 'index.php?_a=recover'?

Link to comment
Share on other sites

"pull the same info"

Do you mean to say these two URLs show the same page? Or is it that they contain the same <title> and <meta description> content in the <head> section?

If it is just the title and meta description, then we can easily change the title.

In /classes/cubecart.class.php, near line 2716 (for CC6011, lines numbers may be off by a few if other edits have already been made):

Find:
	private function _recover() {
		$GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->account['recover_password'], currentPage());

On a blank line after, add:
$GLOBALS['seo']->set_meta_data(array('title' => $GLOBALS['language']->account['recover_password']));

 

Link to comment
Share on other sites

1 hour ago, bsmither said:

"pull the same info"

Do you mean to say these two URLs show the same page? Or is it that they contain the same <title> and <meta description> content in the <head> section?

If it is just the title and meta description, then we can easily change the title.

In /classes/cubecart.class.php, near line 2716 (for CC6011, lines numbers may be off by a few if other edits have already been made):


Find:
	private function _recover() {
		$GLOBALS['gui']->addBreadcrumb($GLOBALS['language']->account['recover_password'], currentPage());

On a blank line after, add:
$GLOBALS['seo']->set_meta_data(array('title' => $GLOBALS['language']->account['recover_password']));

 

I already have that and they both still show the same <title> and <meta description> content.

 

Link to comment
Share on other sites

Right.

And that is because the link to "Recover Password" is /index.php?_a=recover when, if CubeCart was coded appropriately, should be /recover.html.

(See: https://github.com/cubecart/v6/issues/1066 )

As mentioned elsewhere, some pages do not get the SEO treatment:
'account', 'addressbook', 'basket', 'checkout', 'complete', 'confirm', 'downloads', 'gateway',
'logout', 'profile', 'receipt', 'recover', 'recovery', 'remote', 'vieworder', 'plugin', 'unsubscribe'

 

Link to comment
Share on other sites

17 hours ago, bsmither said:

Right.

And that is because the link to "Recover Password" is /index.php?_a=recover when, if CubeCart was coded appropriately, should be /recover.html.

(See: https://github.com/cubecart/v6/issues/1066 )

As mentioned elsewhere, some pages do not get the SEO treatment:
'account', 'addressbook', 'basket', 'checkout', 'complete', 'confirm', 'downloads', 'gateway',
'logout', 'profile', 'receipt', 'recover', 'recovery', 'remote', 'vieworder', 'plugin', 'unsubscribe'

 

I can put the following above the 'index.php' in skins/mican/templates/main.php and then they both show different <title> and <meta description>. Would that work?

{if $smarty.server.REQUEST_URI|stristr:'index.php?_a=recover'}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Millie, Larry Store Recover Password</title>
<meta name="description" content="Registered users can recover their password on this page on Motorhead69 Store.">
</head>
</html>
{/if}
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...