Advise on Creating a Custom Page

pch
@pch
8 years ago
328 posts
Hello,

I would like to have an advise on a good practice on creating a custom page. Note: I am not using the site builder because I am trying to build a multi-lingual site manually. I am using The Elastic Skin.

My main question is: Does a custom page NECESSARY need to be created in the custom skin (under the template folder)? Can it not be created in the audio or video module templates folder?

What are the pros and the cons of creating them in the audio or video module templates folder? Also placing a custom template in the audio or video module, will I loose that template file whenever the audio or video module upgrade?

I have seen that the item_albums.tpl was placed in the audio templates folder and albums have nice urls like eg.: www.site/audio/albums/album_name

So I assume that any template file can be placed there. Am I wrong?

I have created custom pages on my computer for every Audio and video category:

Example:

categoryname_1.tpl (for audio category 1)
categoryname_2.tpl (for audio category 2)

and

categoryname_1.tpl (for video category 1)
categoryname_2.tpl (for video category 2)

What I am trying to achieve is to have URLs like:

www.site/audio/categoryname_1
www.site/audio/categoryname_2

and

www.site/video/categoryname_1
www.site/video/categoryname_2

I know that placing them in the custom skin template's folder, I will need to rename them because I have the same category name for both audio and video and URLs will look like:

www.site/categoryname_1_for_audio
www.site/categoryname_2_for_audio

and

www.site/categoryname_1_for_video
www.site/categoryname_2_for_video

Any advise should be appreciated. Thanks in advance.
updated by @pch: 12/12/16 02:03:16AM
pch
@pch
8 years ago
328 posts
Anyone with a good advise? Thanks
SteveX
SteveX
@ultrajam
8 years ago
2,584 posts
You can use module templates, but you will need to write the module views to handle the templates.


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
paul
@paul
8 years ago
4,326 posts
www.site/audio by default will call the jrAudio module's index.tpl template.
You can overide this by placing a template called jrAudio_index.tpl into you active skin folder.
Any additional URL parameters are then passed to the template via the $_post array so for www.site/video/categoryname_1 {$_post.option} = 'categoryname_1'
So what you would have to do is place all your different audio category template code into the one jrAudio_index.tpl template and switch between them with {if} statements -

{if $_post.option == 'categoryname_1'}
    // 'categoryname_1' code here
{elseif $_post.option == 'categoryname_2'}
    // 'categoryname_2' code here
{elseif $_post.option == 'categoryname_3'}
    // 'categoryname_3' code here
{elseif $_post.option == 'categoryname_4'}
    // 'categoryname_4' code here
{/if}

hth


--
Paul Asher - JR Developer and System Import Specialist
pch
@pch
8 years ago
328 posts
@ultrajam and @paul :

Thank you both for your replies.

@paul :

Awesome! That sounds good. Thanks a lot for the code.

I have few questions with the code you posted:

1) Will the audio or video index remain and still work? (e.: site.com/audio) I don't want to remove it.

2) Will I be able to add/edit Meta tags to generated pages like e.g: www.site/video/categoryname_1 using the JR Meta tags editor?

3) Will these pages be indexed by Search Engines (Google, Yahoo etc)

4) I will list all the files of a specific audio or video category. Will the pagination work?

Thanks for the great support.
michael
@michael
8 years ago
7,721 posts
#1 Check out these docs, let us know if there is anything you don't understand after reading it and I'll get it updated for everyone.

Docs: "altering a module's template"
https://www.jamroom.net/the-jamroom-network/documentation/jamroom-developers-guide/1051/altering-a-modules-template

#2 yes, the meta tag module will allow you to add tags to template you add to your skin.

#3 yes.

#4 yes. As long as you set it up.

Docs: "{jrCore_list} : Pagination"
https://www.jamroom.net/the-jamroom-network/documentation/jamroom-developers-guide/89/jrcore-list#pagination
pch
@pch
8 years ago
328 posts
michael:
#1 Check out these docs, let us know if there is anything you don't understand after reading it and I'll get it updated for everyone.
Docs: "altering a module's template"https://www.jamroom.net/the-jamroom-network/documentation/jamroom-developers-guide/1051/altering-a-modules-template
#2 yes, the meta tag module will allow you to add tags to template you add to your skin.
#3 yes.
#4 yes. As long as you set it up.
Docs: "{jrCore_list} : Pagination"https://www.jamroom.net/the-jamroom-network/documentation/jamroom-developers-guide/89/jrcore-list#pagination

Hi Michael

Thanks for the Docs.
pch
@pch
8 years ago
328 posts
paul:
www.site/audio by default will call the jrAudio module's index.tpl template.
You can overide this by placing a template called jrAudio_index.tpl into you active skin folder.
Any additional URL parameters are then passed to the template via the $_post array so for www.site/video/categoryname_1 {$_post.option} = 'categoryname_1'
So what you would have to do is place all your different audio category template code into the one jrAudio_index.tpl template and switch between them with {if} statements -
{if $_post.option == 'categoryname_1'}
    // 'categoryname_1' code here
{elseif $_post.option == 'categoryname_2'}
    // 'categoryname_2' code here
{elseif $_post.option == 'categoryname_3'}
    // 'categoryname_3' code here
{elseif $_post.option == 'categoryname_4'}
    // 'categoryname_4' code here
{/if}
hth

Hi Paul,

I have done your suggestion.

I am able to visite www.site/audio/categoryname_1 and www.site/video/categoryname_1

But unfortunatly it has completly overwritten my defautl buitl-in JR audio and video page. I didn't want to overwrite them.

Also genarated pages like: www.site/audio/categoryname_1, www.site/audio/categoryname_2, www.site/audio/categoryname_3 are not picked up by the Meta Tag broweser. So there is no way to add Meta tag to these pages.

From the Meta Tag Browser, I can only see: jrAudio_index.tpl and jrVideo_index.tpl

Also, I added a sidebar to jrAudio_index.tpl and jrVideo_index.tpl like this:

{jrCore_include template="sidebar.tpl"}

Unfortunatly it doesn't show on www.site/audio/categoryname_1, www.site/audio/categoryname_2

Please help.
updated by @pch: 09/05/16 04:20:05AM
pch
@pch
8 years ago
328 posts
Hi Paul,

Any idea?

Thanks a lot.
douglas
@douglas
8 years ago
2,791 posts
You'll want to use something other than audio and video as those URL's are assigned to the modules as the default URL.

Have you tried www.site/music/categoryname_1 and www.site/music_video/categoryname_1 instead?

The above would require you to create a music.tpl and music_video.tp but this would keep it from conflicting with the audio and video default URL's.

Hope this helps!


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
pch
@pch
8 years ago
328 posts
Hi Douglas, My Hero, The Best!!!!!

Thanks a lot for jumping in this topic.

Well, I will need to look for some other words other than music because we need to keep our JR more generic and we are not a music-based site.

The method provided by Paul is pretty cool but the problem is that: pages created using this method don't show in the Meta Tag Browser module. So no way to add/edit Meta Tags.

Do you have any idea to get them picked up by the Meta Tag Browser?

Also, template added to these files using the included function don't show.
E.g.: {jrCore_include template="sidebar.tpl"}

Any idea?

Thanks
pch
@pch
8 years ago
328 posts
@paul and @douglas

Any idea?
douglas
@douglas
8 years ago
2,791 posts
Create a jrAudio_index.tpl and add this code:

{jrCore_module_url module="jrAudio" assign="murl"}
{jrCore_include template="header.tpl"}

<div class="block">

    <div class="title">
        {jrSearch_module_form fields="audio_title,audio_album,audio_genre"}
        <h1>{jrCore_lang module="jrAudio" id=41 default="Audio"}</h1>
    </div>

    <div class="block_content">
        {if isset($_post.option) && strlen($_post.option) > 0}
            {jrCore_list module="jrAudio" order_by="_item_id numerical_desc" search1="audio_category = `$_post.option`" pagebreak=10 page=$_post.p pager=true}
        {else}
            {jrCore_list module="jrAudio" order_by="_item_id numerical_desc" pagebreak=10 page=$_post.p pager=true}
        {/if}
    </div>

</div>

{jrCore_include template="footer.tpl"}

upload it to your active skin directory and then create the URL's that Paul posted and that should work.

Here is the jrVideo_index.tpl code:

{jrCore_module_url module="jrVideo" assign="murl"}
{jrCore_include template="header.tpl"}

<div class="block">

    <div class="title">
        {jrSearch_module_form fields="video_title,video_description"}
        <h1>{jrCore_lang module="jrVideo" id=39 default="Videos"}</h1>
    </div>

    <div class="block_content">
        {if isset($_post.option) && strlen($_post.option) > 0}
            {jrCore_list module="jrVideo" order_by="_created numerical_desc" search1="video_category = `$_post.option`" pagebreak=10 page=$_post.p pager=true}
        {else}
            {jrCore_list module="jrVideo" order_by="_created numerical_desc" pagebreak=10 page=$_post.p pager=true}
        {/if}
    </div>

</div>
{jrCore_include template="footer.tpl"}

Hope this helps!


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
pch
@pch
8 years ago
328 posts
Hi Douglas,

Thanks a lot for your help.

One problem has been fixed by your code: no more conflict with the audio and video default URL's.

The second problem still remains:

As pages created by Paul's solution are virtually (dynamically) created (e.: www.site/audio/categoryname_1, www.site/audio/categoryname_2), they don't appear in the Meta Tag Browser. So there is no way add/edit their Meta Tag, no way to get them properly indexed by major Search Engines.

In the Meta browser, I just see jrAudio_index.tpl and jrVideo_index.tpl . I don't see categoryname_1, categoryname_2, categoryname_3 etc.

Any idea on how to get them show in the Meta Tag Browser?

Thanks
douglas
@douglas
8 years ago
2,791 posts
You would have to have a separate page for each category_1 etc... in order to use the meta tag module.

Are you trying to add keywords and descriptions to each category? Or are you trying to change the page title for each category?

Thanks!


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
pch
@pch
8 years ago
328 posts
Hi Douglas,

I am trying to change the page title, page description, page keyword, og:image etc for each category page.

I would like every category page to get indexed by search engine.

Having a separate page for each category would be the solution but the problem is that I will have URLs like:

www.site/audio_categoryname_1
www.site/audio_categoryname_2

and

www.site/videos_categoryname_1
www.site/videos_categoryname_2

What I have been trying to achieve is to have URls like:

www.site/audio/categoryname_1
www.site/audio/categoryname_2

and

www.site/videos/categoryname_1
www.site/videos/categoryname_2

Paul's solution allows me to do that but unfortunately the dynamic pages created don't show in the Meta Tag Browser.

I am completely lost.

Tags