Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Secondary Menu?


Go to End


20 Posts   13263 Views

Avatar
areikiera

Community Member, 26 Posts

15 February 2008 at 11:07am

You guys are wonderful, and I'm sure stunningly handsome, geniuses! Thank you! I'm still using the themes folder, thanks to willr's advice, but I've got it nearly working.

So, I've got the Database rebuilt and the ShortCut Page created. I've added a link within that shortcut page and everything was going peachy until I tried to add the "% include ShortCut..." I'm sure it inserted the code from ShortCut.ss (I'm getting a parse error), so I'm guessing that the problem is that it's just not inserting anything in the $ ... sections from the database. Does that sound right?

If I am right, I'm guessing the only problem is that my "% control Page(ShortCut/)..." link in the Include File is wrong. This is my file structure...

mysite > code > ShortCut.php
ShortCutColumn.php

themes > mythemename > templates > Includes > ShortCut.ss
> Page.ss

I'm including the "% include ..." on Page.ss, and in the CMS, I've created the page called ShortCut, located at localhost:3000/shortcut/

What would the correct link be in this case?

In case it's significant, the Parse Error I'm getting is "Parse error: parse error, unexpected '}' in..."

Thanks again!

Avatar
SilverRay

Community Member, 167 Posts

15 February 2008 at 2:33pm

Hmm, it might be a typo somewhere?

I would start with giving the page you created in the cms another url, just to make it easier to differentiate from the other shortcut-like names and to make sure things are not in conflict... so give the page you use in the cms to manage your list of links (which would be still based on the ShortCutColumn.php page type) a different url, for instance 'testurl'. Then in your control block in the include-file use 'control Page(testurl/)'. Then give your include-file a different name as well, like 'testinclude.ss'. Then refer to this include on your other pages with the include statement. Does this change things?

Avatar
areikiera

Community Member, 26 Posts

16 February 2008 at 4:07am

Edited: 16/02/2008 5:19am

I tried renaming ShortCut.ss to Utility.ss, changed the references to it, renamed the ShortCutColumn page in the CMS, and still have the same issues.

I'll restate the problem I'm having in case any brave new souls want to join in on the fun:

--> When I type

<% include Utility %>
, I receive this error: "Parse error: parse error, unexpected '}' in..."

I'm sure the php files in the code folder are working, at least the part affecting the CMS and database, because I can add a link in the New Tab "Section1" on the new page I created with the page type 'ShortCutColumn', and it stores it. And when I take out any dynamic link creation in Utility.ss, and just make a simple list, the list shows up.

In case anybody can spot a problem, here's my code.

Page.ss
Utility.ss
ShortCut.php
ShortCutColumn.php

The last two are the same as SilverRay's original posts, which is exactly the code I have.

GARR!

Thanks again!

Oh, and in case anyone can answer this for me, is it true that it's a sport in New Zealand to catch deer by jumping out of a helicopter onto them? That's really really impressive!

Avatar
SilverRay

Community Member, 167 Posts

16 February 2008 at 1:46pm

Edited: 16/02/2008 1:46pm

In _config.php, if you put this in:

ContentNegotiator::disable();

it still gives the error?

Avatar
Sean

Forum Moderator, 922 Posts

16 February 2008 at 4:55pm

Edited: 16/02/2008 4:59pm

<% control Page(home/) %> should probably be written as <% control Page(home) %>

The trailing slash (/) at the end is probably not required, and it could break the SS templating engine. Remove it, and give it another try. :-)

ContentNegotiator will only switch around the page DOCTYPE, and the /> self closing on tags, this won't affect the fact that there's a SS template error.

Cheers,
Sean

Avatar
SilverRay

Community Member, 167 Posts

16 February 2008 at 5:02pm

ˆˆˆI'll second that...

Avatar
areikiera

Community Member, 26 Posts

19 February 2008 at 4:19am

Edited: 19/02/2008 5:14am

I've reinstalled Silverstripe, to avoid any variable problems that I may have caused some other way.

I've rewritten Utility.ss, the page that calls the links created in the CMS, to error trap the problem. I'm no longer getting a parse error, but the links just aren't being called.

Is SCSection1 the correct call for this? SilverRay, you mentioned typos, is anything in this code supposed to be different? Maybe control Page(...) might have the problem? It's linking to the proper page, is there a different call to the page?

Utility.ss:

<% control Page(utility-links) %>
<ul>
<li><a href="ShortCutLocation" title="ShortCutTitle">ShortCutName</a></li>
<% if SCSection1 %>
<% control SCSection1 %>
<li><a href="$ShortCutLocation" title="$ShortCutTitle">$ShortCutName</a></li>
<% end_control %>
<% else %>
<li>No Links called</li>
<% end_if %>
</ul>
<% end_control %> 

This code returns the test link: "ShortCutName" and my error trap: "No Links called"

Are there any errors in the ShortCutColumn.php and ShortCut.php files? I don't have much of an eye for Silverstripe PHP code yet, but it doesn't seem that there is a reference to ShortCut.php in the ShortCutColumn.php file. Maybe there doesn't need to be.

Thanks for sticking with me through all this, SilverRay! And I really appreciate everyone's help!

Thanks again for the suggestions!

Avatar
SilverRay

Community Member, 167 Posts

19 February 2008 at 1:11pm

OK, I tried the exact code I gave you (the two blurbs I pasted a few posts before) and the rewritten code you stated above, and it works when I try it in a test site! So, there are no typos... there must be something else going on. So for instance, it sounds silly but it is easy to forget, did you actually enable the little checkbox left to the link you made in the list under the 'section' tab in the page you use to manage the links (in the cms)? And then really published the page? Did you put ?flush=1 after the url in the browser to empty the template cache after you've made changes? In your reinstalled situation, you made sure that the data actually saves in the database? Things like that... other than that I don't know what to tell you...

Just to answer your other questions: ShortCut.php is there only to have a dataobject in order to have a table in the database for your links, and ShortCutColumn.php is only there to be able to give you a page in the cms with which you can manage your dataobject. So the code you wrote is in itself correct...

Any page we can see (in other words, can you put the whole thing on a server)?