Question
On v5.0, is there a way to give each page an individual title? Currently this is set globally in the template, but I'd like to have a different title on each page.
Answer
v5.1 includes this functionality as standard, so upgrading 5.0 to 5.1 will provide this.
If you wish to customize v5.0 to do this, some coding will be required. However the change should be simple enough.
Firstly, load up your template, and find where the title tag is. By default, that was:
<title>CactuShop ASP Shopping Cart by Cactusoft</title>
Change this to a new custom cactushop tag:
<title>xxxPAGETITLExxx</title>
What we now need to do is to replace this with a real string in the buildpage. Load up buildpage.asp in the /includes folder. Find the following line at the bottom of the page:
strPageBaseText = Replace(strPageBaseText,"xxxCURRENCYMENUxxx",strCurrencyListHTML)
This is in the function that reads in the template and replaces all the cactushop tags (like xxxCURRENCYMENUxxx etc) with actual HTML. After this line, add in the following:
If strPageTitle = "" then strPageTitle = "My Default Page Title"
strPageBaseText = Replace(strPageBaseText,"xxxPAGETITLExxx",strPageTitle)
This code basically sets the page title to "My Default Page Title" if it hasn't already been set, then replaces our tag with this title. Obviously you can change the 'My Default Page Title' to what ever you like. If you look at the shop now, all pages should have the default title set as their title. So far so good.
Now all that's needed is to set your custom page names. Lets take default.asp. Straight after the copyright notice, stick in this code:
strPageTitle = "This is the default.asp page"
Now you'll notice that the default.asp page has this as the title. You can do this on any ASP pages that you like. The only important thing is that this line always appears before this code:
Call ReadFromTemplate(strTemplateLocation, aryPageTemplate, strBasketHTML, strCategoryListHTML)
Because this is where the template is read in. With a bit of ASP you could change the title based on the querystring, for example, on prodtype.asp:
Select Case PT_ID
Case 198: strPageTitle = "This is the category page of ID#198!"
Case 199: strPageTitle = "This is the category page of ID#199!"
Case Else: strPageTitle = "This is another category"
End Select