# Use sub folder url with share\_layouts

**URL:** <https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681>\
**Category:** Radiant CMS\
**Created:** [December 15, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681 "2008-12-15T15:53:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [December 15, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681/1 "2008-12-15T15:53:39Z")

</div>

Hello,

I’m using share\_layouts in a page ‘/project’ which is using a layout  
‘Content’.  
I created an extension, with routes, controllers etc. to map the project  
page.  
Everything is working, the ‘part’ is display thanks to the layout.

Then, I created a new page ‘/project/list’. I maped it again etc., but  
the final display is strange : I got the content of the ‘project’ page  
(only from database not from my view), the content of my new page and  
the view of my new page.  
In fact the normal page + ‘/project’ content.

Is it normal or did I forgot something?

Thanks  
Vincent

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [December 15, 2008, 9:55pm UTC](https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681/2 "2008-12-15T21:55:38Z")

</div>

Hello Vincent. I’ve been working with ShareLayouts a bit recently,  
maybe I can help. Can you give more details, though?

I’d like to know:

```
* Are you using the latest version of ShareLayouts from GitHub?
* Can you provide your route(s)?
* Can you provide any of your actions/views (enough to show what's
  using what).
* It sounds like you're using an Application Page in Radiant with
  the URL of /project/ is this correct? Is there anything fancy
  there? Do you have an Application Page at /project/list too?

```

-Chris

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [December 15, 2008, 11:43pm UTC](https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681/3 "2008-12-15T23:43:30Z")

</div>

Hello, thanks ! I will give you more informations :

I created two pages :  
Projects =\> /projects (with body content ‘Here is Projects’)  
Create =\> /projects/new (with body content ‘Here is new project’)

Then, I created a new extension with the following routes :  
map.with\_options(:controller =\> ‘projects’) do |project|  
project.project\_index ‘/projects’, :action =\> ‘index’  
project.project\_new ‘/project/new’, :action =\> ‘new’  
end

The controller project is a simple controller like that :  
class ProjectsController \< ApplicationController  
radiant\_layout ‘’  
skip\_before\_filter :verify\_authenticity\_token  
no\_login\_required

def index

end  
def new

end  
end

In the two view, I have something like :

- content\_for :extension do  
content for project…

- content\_for :extension do  
content for new project…

Back to the backend, I’m using a layout which include parts ‘body’ and  
‘extension’.

Now with share\_layouts this is my result :

/projects  
Here is Projects  
content for project…

/projects/new  
Here is Projects  
content for new project…

The way is normal for the first link, but the page content of the second  
come from the first one.  
Let me know if you need more informations.  
I’m not using fancy extension except the vhost extension (for multi  
site).

Thanks !  
Vincent

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [December 16, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681/4 "2008-12-16T17:50:55Z")

</div>

Hi Vincent,  
I’ve been using Radiant for just a few days now, but I recall reading  
something about inheriting content from parent pages through the page  
parts. If I get your descriptions right, _part_ of the content from  
/projects is rendered in subpages, so I guess that might indeed result  
from said feature. I’d have liked to look it up for you, but I’m in a  
bit of a hurry.

Hope this helps  
Chris

-------- Original-Nachricht --------

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [December 16, 2008, 4:36pm UTC](https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681/5 "2008-12-16T16:36:37Z")

</div>

I tried the last version of share\_layouts on github but I got the same  
problem… maybe it’s a mistake of one of my extension.  
I will check in a new Radiant project later.

I have another problem with share\_layouts. I created a page and add some  
content :

## 
  

### Query(s)
 " /\>   

And in my view :

- content\_for :title do  
= @project.topic

- content\_for :project\_id do  
= @project.id

- content\_for :query do  
%ul

It is working in development mode but not in production. What could  
change between both of them?

Thanks !

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [December 16, 2008, 7:03pm UTC](https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681/6 "2008-12-16T19:03:03Z")

</div>

Christian, this is true – sortof. I recently submitted some patches to  
Sean that have been rolled into shared\_layouts. One of these changes  
now lets you create a sub-page within Radiant like Vincent describes.  
If you fail to create a sub-page, then the old behavior – the one you  
described – prevails. This way you can use the sub-page’s breadcrumbs,  
title, and, page parts.

This is also why I wanted to know if Vincent was using this latest  
version of shared\_layouts.

Vincent, try pulling the latest version and see if it fixes things for  
you.

-Chris

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [January 4, 2009, 8:39pm UTC](https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681/7 "2009-01-04T20:39:55Z")

</div>

Hello,

I found new stuff linked (I hope) to my bug with share\_layouts.

In the rails page model, I did a debug in the console :  
def build\_parts\_from\_hash!(content)  
content.each do |k,v|  
puts "$$$$$$$$ part : " + k.to\_s  
puts "$$$$$$$$ part content : " + v  
(part(k) || parts.build(:name =\> k.to\_s)).content = v  
end  
end

And this is my result :

$$$$$$$$ part : my\_part  
$$$$$$$$ part content :  
I’m in the part  
$$$$$$$$ part : body  
$$$$$$$$ part content :  
WARNING: You’re using the Ruby-based MySQL library that ships with  
Rails. This library is not suited for production. Please install the  
C-based MySQL library instead (gem install mysql).

I’m using mysql with xampp, the problem is maybe coming from this  
configuration?

I tried to install the mysql gem, but I have some mysql package missing  
:  
checking for mysql\_query() in -lmysqlclient… yes  
checking for mysql\_ssl\_set()… yes  
checking for mysql.h… no  
checking for mysql/mysql.h… no  
\*\*\* extconf.rb failed \*\*\*

I will try to install mysql from scratch.  
But is it normal, do you have any idea?

Thanks,  
Vincent

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [December 29, 2008, 5:12pm UTC](https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681/8 "2008-12-29T17:12:20Z")

</div>

I tried the last version of share\_layouts but I got the same errors.  
So, I decided to test it from scratch with a fresh radiant 0.6.9,  
share\_layouts, and my projects extension. It’s working, but now I got  
sometimes another error.

Example : I created a /project page and a layout with the following  
content : \<r:content page=“test” /\> (in both of them, it’s for a test).  
In production mode, it’s working, but if I add some controller /  
extension, it’s not working (the content of the page is not display, but  
the content from the layout is display, so it’s realy strange). If I  
add/remove another controller / extension it’s now working… I don’t  
understand, because it’s the case with any controller / extension. If  
I’m running in development mode, everything is working fine.

Is it a cache problem or something like that?  
Anyone had the same error?

Thanks,  
Vincent

---

<div class="post-metadata">

**Author:** ![vpredoehl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/67e7ee/32.png) [@vpredoehl](https://www.ruby-forum.com/u/vpredoehl)\
**Post date:** [January 4, 2009, 10:47pm UTC](https://www.ruby-forum.com/t/use-sub-folder-url-with-share-layouts/155681/9 "2009-01-04T22:47:55Z")

</div>

You are missing the mysql development headers. Depending on your  
distribution they come in various packages. Something along the lines of  
mysql-devel or something like that

Jeff
