Log in | Register | Lost password

Goto page: [-1] 1 - 2

Bottom
Guppy: Merging Categories/Lists and Publications
  • Posted: 05.06.2005, 13:34
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Lord? Well that sounds good :-)

    Just wanted to report that i got everything working.
    As i don't know much php the code is probably a mess, but well, it works.

    I combined the generic plugin with frank_r's pub_title-plugin to get the pids retranslated to the publication name in my template, where i want to show the context links.
    shouldn't be too hard to write an integrated plugin but that's beyond my skill.

    Further details on my solution can be found here: here (on page 2)
  • Posted: 06.06.2005, 07:50
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Seeing what is possible using plugins i was wondering, if it isn't a good idea, to create a plugin along the lines of the "pagesetter link"-button which is integrated into htmlarea. (similiar to the photoshare html-plugin).
    the plugin could call the popup window where you can select items from different publication types using checkboxes. these information are passed to the template as an array and called in a similiar way obstacle explained in this thread.





    [Edited on 6/6/2005 by Andreas]
  • Posted: 25.10.2005, 06:41
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0

    obstacle

    LOL! i should have seen that one coming: i've updated it, still available here (http://obstacle.com/_bin/input.generic.txt). Two new variables: "multiple" and "multiple_size". Pretty self explanatory: when the former is set to true, you will have the possibility of using multiple selections. "multiple_size" set the number of viewable rows.

    Note 1: the plugin uses a different field type depending on "multiple"'s value - INT when single, VARCHAR when multiple. So it's preferable not to switch multiple/single on the fly; erase the field and/or create a new one.

    Note 2: with "multiple", the values stored are semi-colon separated ( 23;4;34;5;6; - which explains the VARCHAR). You may need to code a quick plugin to use the data. I'll refer you to the plugin in this very thread, an easy enough tweak to have it return a usable array.

    g'luck! jeff :)


    I'm not quite sure how to proceed on displaying the selected publications here. I have the input plugin working nicely, but now I need to display it. I think that maybe with Jorn's conversion to pnForum from XForum that some code has been lost in this forum, or there's just too many different snippets here for me to see what I need. Can someone help out? Maybe a link to "display multiple select pub" plugin?

    Thanks
  • Posted: 25.10.2005, 18:58
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0

    Quote

    I'm not quite sure how to proceed on displaying
    the selected publications here. I have the input
    plugin working nicely, but now I need to display
    it. I think that maybe with Jorn's conversion to
    pnForum from XForum that some code has been lost
    in this forum, or there's just too many different
    snippets here for me to see what I need. Can
    someone help out? Maybe a link to "display
    multiple select pub" plugin?


    Well technically, you end up with a field that either stores a PID or a list of PIDS, what you do next is up to you, and is handled at template level.

    Example: if variable name is "generic", you could link to that pub like this:

    Code

    <a href="index.php?module=pagesetter&func=viewpub&tid=your_tid_here&pid=<!--[$generic]-->">LINK</a>


    If you're using a multiple select var, i don't see any options other than sending that info to a Smarty plugin for processing, kinda like this:

    Code

    <!--[your_plugin pids=$generic]-->


    You could also send it directly to your homebrewed API (i prefer this method, that way i don't have to code a Smarty plugin and i stick to "regular" coding. Plus, it centralizes everything):

    Code

    <!--[pnmodapifunc modname=MODULE_NAME func=FUNC_NAME pids=$generic]-->


    I hope this is making any sense. G'day! jeff :)
  • Posted: 26.10.2005, 04:30
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Sorty of. I am doing a "multiple". So you're coding your own module that stores your API's for you? I'm surprised that this is easier than doing a plugin, but then I neven't delved into smarty plugins either.
  • Posted: 26.10.2005, 07:31
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    OK, I just plunged in to see where I could get.

    I now have a plugin:

    Code

    function smarty_function_pagesetter_pubinfo($params, &$smarty)

    {

    extract($params);

    unset( $params );



    if( !$tid )

    {

    $smarty->trigger_error( "pagesetter_pubinfo: missing parameter 'tid'" );

    return false;

    }

    if( !$pid )

    {

    $smarty->trigger_error( "pagesetter_pubinfo: missing parameter 'pid'" );

    return false;

    }



    $pubinfo = pnModAPIFunc ( 'pagesetter', 'user', 'getPub',

    array( 'tid' => $tid,

    'pid' => $pid ) );

    $smarty->assign($assign, $pubinfo);


    and a template with this:

    Code

    <!--[pagesetter_pubinfo pid=1 tid=5 assign="pubarray"]-->



    <!--[foreach from=$pubarray item=curr_id]-->

    id: <!--[$curr_id]--><br />

    <!--[/foreach]-->


    and it successfully dumps out data from the requested doc. Yea! But I'm stumbling on what should be easy: how do I figure out how to reference the data to get the item I want? I'm kinda weak on smarty, but I don't see anything like a dump_r() function that will show me the array I get with keys.

    TIA for any suggestions.
  • Posted: 26.10.2005, 12:26
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Sorry, didn't realize i was making it more complicated with the API thing - just a habit of mine to create a module per client.

    You're definitely on the right track: what you have in a multiple select setup is a list of PIDs contained in a string. So you want to 1. turn that string into an array and 2. run a loop through that array to retrieve the content. So your plugin call could be:

    Code

    <!--[pagesetter_pubinfo pid=1 tid=5 pids=$generic assign="pubarray"]-->

    Your function could look like this:

    Code

    1.

    function smarty_function_pagesetter_pubinfo($params, &$smarty){

    extract($params);

    unset( $params );



    // 1. turn string into Array

    if(!$pids){

    //i trigger error here but it could react differently

    $smarty->trigger_error( "pagesetter_pubinfo: missing parameter 'pids'" );

    return false;

    }else{

    $pids = explode(";", $pids);

    }



    if( !$tid )

    {

    $smarty->trigger_error( "pagesetter_pubinfo: missing parameter 'tid'" );

    return false;

    }

    if( !$pid )

    {

    $smarty->trigger_error( "pagesetter_pubinfo: missing parameter 'pid'" );

    return false;

    }



    //2. loop through the array

    foreach($pids as $i){

    $pubinfo[] = pnModAPIFunc ( 'pagesetter', 'user', 'getPub',

    array( 'tid' => $tid,

    'pid' => $i) );

    }

    $smarty->assign($assign, $pubinfo);

    From here, your loop would look like

    Code

    <!--[foreach from=$pubarray item=i]-->

    id: <!--[$i.core.pid]-->; other_var: <!--[$i.other_var]-->;<br />

    <!--[/foreach]-->

    Almost there! jeff :)
    Caveat: coding for memory, didn't test this.
  • Posted: 28.10.2005, 07:07
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    OK, I've got the "other" variables working (i.e.,

    Code

    <!--[$pubarray.lastname]-->
    ), but the "core" one's don't show. I've tried

    Code

    <!--[$pubarray.core.author]-->, <!--[$pubarray.author]-->, <!--[$pubarray.core.pid]-->,

    <!--[$pubarray.pid]-->
    .

    Is there a way to dump an array in smarty that shows the keys?

    BTW, my strategy was to get this working with just one pid, then when I knew that was working make it handle an array of pid's (for multiple). Your example might be helpful with that, but one of the options I was considering was exploding the list of pids in the template rather than the plugin, and then processing each pid in a smarty foreach loop. That way once plugin would work for both single and multiple selects, and display logic would stay in the display file. Your thoughts?
  • Posted: 29.10.2005, 04:02
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Aha!

    Code

    <!--[foreach from=$pubarray item=curr_id key=key_id]-->

    <!--[$key_id]-->: <!--[$curr_id]--><br />

    <!--[/foreach]-->


    reveals keys such as core_pid, etc.
  • Posted: 02.11.2005, 01:52
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Howdy-

    I have implimented the multiple select user plugin and it works (phew) and it will return a string of numbers of course. Now here's my question:

    In the below code you can see that I first fetch the logged in user's pn uid and store it as a variable uid. I then TRY to match it against the field that contains the string of numbers from the plugin; $users. Well this doesn't quite work as smarty, being smart tries to match the var uid with the WHOLE string, something like this: 2(uid) = 2;4;14($users) and of course it doesn't match.

    Code

    <!--[pnusergetvar name="uid" assign=uid]-->

    <!--[if uid = $users]-->

    blah blah

    <!--[else]-->

    blab blab

    <!--[/if]-->


    So what I need a bit of help with is a method for doing this. From all that I've tried ina template with smarty I have an unsettling feeling that it'll have to be done with a filter- and I don't know how to do that, yet...

    I'm trying to have it so that the author of the publication can select who (multiple people) from the pn user list can see certain fields...



    edited by: RemShowdown, Nov 06, 2005 - 06:26 AM
  • Posted: 02.11.2005, 01:53
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Ok, I have another question, bear with me...

    How do I turn the array of user id's into usernames?

    And can I replace the ";" with a blank space?

    Thank you much!




    edited by: RemShowdown, Nov 02, 2005 - 05:14 AM
  • Posted: 25.02.2006, 09:32
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Nice topic! I'm starting to use guppy plugins after seeing what can be done from reading this, good post and thanks for the info :-)

Goto page: [-1] 1 - 2

Template courtesy of Designs By Darren.