21301 Posts in 5736 Topics by 2603 members
| Go to End | ||
| Author | Topic: | 3006 Views |
-
Re: Generator HTML Tag

29 September 2011 at 10:52pm Last edited: 29 September 2011 10:53pm
Hi Bastir
There are a couple of things going wrong here...
Restore the original SiteTree.php. Changing core code makes it hard to upgrade. (Willr said
Copy the MetaTags() function from SiteTree.php to your own Page.php)Ed's GetCanonical and my CanonicalURL are two different techniques. you don't need both. I think the CanonicalURL method is simpler, so is recommended if you're just getting started with SS.
After changing the .ss file, you need to browse to the page adding ?flush=1 to the URL to clear the cache.
Thanks,
Jules (inCharge Ltd) -
Re: Generator HTML Tag

30 September 2011 at 1:57am
Hi Jules,
Thanks for the advice!
I added the code from your post to the end of the page.php an into the page.ss below the Basetag.
after that i reloaded everything by ?flush=1 and i also tried dev/build
but i only get a empty result <link rel="canonical" href="" />
is their any additional configuration necssary?
URL: www.inzenaro.de
thy in advance
Best Regards bastiR
-
Re: Generator HTML Tag

30 September 2011 at 3:36am
You can easily find out which bit is not working with a bit of investigation.
When you put a $Tag in the .ss, then it calls the function in the Page class and replaces $Tag with the value returned by the function.
So if you have this in Page.php...
function CanonicalURL() {
return "hello";
}...and this in Page.ss
<div>$CanonicalURL</div>
then the result in teh browser should be
hello
Does that work for you?
-
Re: Generator HTML Tag

30 September 2011 at 7:41pm
Hi Jules,
No i only get a empty <div></div> so i Think the problem is in the Page.php
------------------------------
<?php
class Page extends SiteTree {public static $db = array(
);public static $has_one = array(
);}
function CanonicalURL() {
return "hello";
}class Page_Controller extends ContentController {
/**
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
* permissions or conditions required to allow the user to access it.
*
* <code>
* array (
* 'action', // anyone can access this action
* 'action' => true, // same as above
* 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
* 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
* );
* </code>
*
* @var array
*/
public static $allowed_actions = array (
);public function init() {
parent::init();// Note: you should use SS template require tags inside your templates
// instead of putting Requirements calls here. However these are
// included so that our older themes still work
Requirements::themedCSS('layout');
Requirements::themedCSS('typography');
Requirements::themedCSS('form');
Requirements::themedCSS('flexslider');
Requirements::css(SSPE_DIR."/css/960gs/960.css");
}
}----------------------------------
any idea?
Best regards bastiR
-
Re: Generator HTML Tag

30 September 2011 at 8:34pm
The good news is that I can't see anything wrong with your code. The bad new is...I can't see anything wrong with your code.
Maybe the Page.php you're editing isn't the one that SilverSitripe is using. What folder is it in? Is it really called Page.php?
Are flexslider.cc and 960.css being included in the header?
What happens if you add the following code inside the init() function?
throw new Exception("Hello!");
-
Re: Generator HTML Tag

30 September 2011 at 8:59pm
Hi,
path: mysite/code/page.php
Flexslider and 960.css are included in the header.
i insert the code snippet to the page.php like:
public function init() {
parent::init();// Note: you should use SS template require tags inside your templates
// instead of putting Requirements calls here. However these are
// included so that our older themes still work
Requirements::themedCSS('layout');
Requirements::themedCSS('typography');
Requirements::themedCSS('form');
Requirements::themedCSS('flexslider');
Requirements::css(SSPE_DIR."/css/960gs/960.css");
throw new Exception("Hello!");
}
}on the frontend i get an Error 500 on ervery page.
in the html source code the canonicla and div is away.
i'm totaly helpless what is the failure.
Thans for your help in advance:)
-
Re: Generator HTML Tag

30 September 2011 at 9:27pm
Ah, I see it. CanonicalURL is outside the Page class. You need to move it inside.
Change...
}
function CanonicalURL() {
return "hello";
}...to...
function CanonicalURL() {
return "hello";
}} /* end of the Page class */
> i'm totaly helpless what is the failure.
No you're not! Don't just scratch your head saying 'it SHOULD work'. Try different tests to close in on the problem.
-
Re: Generator HTML Tag

30 September 2011 at 10:00pm
Thanks a lot, not it works and i'm happy again;)
Have a nice weekend
| 3006 Views | ||
| Go to Top |

