can i add a page to a module?

blindmime
@blindmime
11 years ago
772 posts
How do I add a page to a module?

I have an Aparna-generated module called agTask, so the item_index page url is domain.com/profile/task/. It's an index of Task items, of course. I'd like to add pages with different lists of tasks like domain.com/profile/task/invoiced.

How do I do this?
updated by @blindmime: 06/12/14 02:04:25PM
SteveX
SteveX
@ultrajam
11 years ago
2,587 posts
Do something similar to profile_view_jrBlog_default in your agTask profile.php

Instead of checking $_post['_1'] for 'category', check for 'invoiced' and serve up your view.


--
¯\_(ツ)_/¯ 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 :)
blindmime
@blindmime
11 years ago
772 posts
Thanks, Steve. What's the method for creating a profile.php file for a module that doesn't have one?
SteveX
SteveX
@ultrajam
11 years ago
2,587 posts
Copy it from jrBlog and change the names to agTask?


--
¯\_(ツ)_/¯ 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 :)
blindmime
@blindmime
11 years ago
772 posts
Are there any config settings in include.php or anything in index.php, etc. that need to be set?
brian
@brian
11 years ago
10,149 posts
blindmime:
Are there any config settings in include.php or anything in index.php, etc. that need to be set?

No - if the core sees profile.php it basically "hands over" routing of that module's profile pages to the script.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
michael
@michael
11 years ago
7,806 posts
These 2 youtube vids might help:
Add a section to the profiles (Jamroom CMS Development)
Jamroom 5 CMS: adding to the profiles


If you add a file at:
agTask/templates/index.tpl

That will show up at
site.com/task

What you want to do is create a view in the profile.php file.

You can do that by using the default view function name:
function profile_view_agTask_default($_profile,$_post,$_user,$_conf)
{ //..... do something }

check out how the jrBlog/profile.php file looks for an example of it.

OR You can specifically define views to map to urls

function profile_view_agTask_invoiced($_profile,$_post,$_user,$_conf)
{ //..... do something }

the default one will map to
domain.com/profile/task/
the second one will map to
domain.com/profile/task/invoiced

but you could use the first one to handle invioced if you wanted to too. The 'invoiced' will be in the $_post var.
blindmime
@blindmime
11 years ago
772 posts
OK, cool. So now I'm using task/invoiced to list items invoiced during a month which is passed like http://domain.com/profile_name/task/invoiced?month=April

Is there a different way of specifying that url, like http://domain.com/profile_name/task/invoiced/month/April? That doesn't work, but I'm just wondering if there's a different way you like to do it in jr5.
SteveX
SteveX
@ultrajam
11 years ago
2,587 posts
You'd just check the $_post as normal.

So you could use
if ($_post['month'] == "April") {
// do this...
// your code here:
}

Or check for $_post['_1'], $_post['_2'] etc.

Check out the docs on reading the post if you havent read them already:
https://www.jamroom.net/ultrajam/documentation/code/1683/reading-the-post


--
¯\_(ツ)_/¯ 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 :)
blindmime
@blindmime
11 years ago
772 posts
Allright, so /task/invoiced/month=March works.

One more thing. Can I create other file types from the profile? I'd like to do something like this to create a csv file the client can download:
function profile_view_agTask_March($_profile,$_post,$_user,$_conf)
{ return jrCore_parse_template('March.tpl',$_profile,'agTask'); }
I can't use "March.csv" there, evidently. I do have March.tpl creating the data fine, but it comes out with a profile header and footer I don't want, naturally. Is there a jrCore_parse_file function or something?
michael
@michael
11 years ago
7,806 posts
if you use "/task/invoiced/month=March" then $_post['month'] will equal 'March' but if you want to keep it clean

/task/invoiced/March


$_post['option']
$_post['_1']
$_post['_2']
$_post['_3']

one of those above will also equal march. not sure which, so you'd need to check.

--edit--
as for the file export, look in the jrChainedSelect module it has a way to export and import a .csv file
function view_jrChainedSelect_export()
//.... get the data ready

    header("Content-type: text/csv");
    header("Content-Disposition: attachment; filename=\"ChainedSelect_{$_rt['set_name']}.csv\"");
    asort($_r1);
    $out = implode("\n", $_r1);
    echo $out;

updated by @michael: 05/13/14 01:53:16AM

Tags