salguod

Formatting Action Stream

Vote 0 Votes

I'm using AS 2.0 and I'm trying to figure out how to format my stream. I'm reading through the docs, but I'm having a hard time figuring it out.

All the example templates simply have the MT:streamaction tag to return the default output as defined by AS or the individual plugin. This results in varying output depending on the service.

For example, the default Twitter stream is [author] Tweeted [tweet] and has the link to the tweet in the word 'Tweeted'. The default Facebook stream is [author] posted [post] and the link to the post is the post text itself. The default Blip stream is only [author] blipped on "[artist] [song]" and doesn't include the text of the blip.

I want to try to make my stream format common across streams, using the Twitter default as a model, but I'm having a hard time figuring out the right template code. As I said, I'm trying to sort through the docs, but I'm having a hard time making sense of it so I thought I'd ask here as well. Can anyone help?

Reported on Movable Type 4.2

7 Replies

| Add a Reply
  • That's all determined in the streams.yaml in the "html_form" section.

    You should be able to see what is going on there and tweak appropriately

  • Are you saying that the best way to do this is to change the streams.yaml rather than in the template? I'd rather not do that as it's just something to remember to replace during an upgrade. Plus, with other add on AS plugins like blip.fm, that's more *.yaml files to edit and maintain.

    I'd prefer to do it through template tags, is that possible?

  • You can always use the regex_replace attribute on the stream, but I wouldn't have a clue what regex function you'd want to use!

    You can create your own stream format for each stream using the MTStreamActionVar name="xxxx" tag, and the stream vars listed here but you're talking quite a lot of work!

  • Regex? I know what it is (but that's it) but I'm lost as to how it applies here. No matter, I couldn't regex my way out of a wet paper bag.

    So, it seems like I'd have to have specific templating for each stream type, and quite possibly for each stream. Painful.

    Action Streams is a great plugin, I just wish it wasn't so hard to customize. Well, actually it's not hard to edit the streams.yaml file, I just have an aversion to editing source files to customize my site.

    Would there be away to keep the customizations in a separate *.yaml file? That way, when upgrading all those customizations wouldn't need to be reapplied.

    Is there a way to add comment to a *.yaml file? If I'm going to edit it, I'd prefer to comment out the original section and leave it in as a reference.

    A great AS enhancement would be a way to define alternate recipes for each stream through the UI and select them via template tags or in the UI.

  • A "subscribe to this post" would be really handy here, i always forget to check back, sorry!

    Depends if you want to change them all and how much you want to change. For example, I take out the author name as I'm the only one in the stream, so it's superfluous. I do that with this line:

    <mt:setvar name="mt_author_display_name" value="Richard">
    ...
    <mt:setvarblock name="name_regex">/<mt:var name="mt_author_display_name">/</mt:setvarblock>
    ...
    <mt:StreamAction regex_replace="$name_regex","">
    

    So it really depends what you want to do, and how many you want to do it to. I have no idea what supplying another YAML that redefines some of the services will do to it, how does it decide which one to override?

  • So, let's see if I understand what this does.

    The first line defines the template variable "mt_author_display_name" and sets its value to "Richard".

    The second line sets defines the template variable "name_regex" and sets its value to the value of the variable mt_author_display_name with a preceding and trailing /. So /Richard/.

    The third line says replace any instances of /Richard/ with nothing. I'm not versed in regex, but I assume the '/' wrapping 'Richard' makes the regex work, right?

    Here's a silly question: Why not just use value="" in line 1? That's what I did and it seemed to work. Is there a reason not to do that?

    Back to the question, in my case I like the Twitter stream, but I want to change the blip.fm and Facebook streams. If I understand things right, I'd need some complicated if statements and custom temptating for each stream.

    Something like if service=blip fm, some formatting, if service=facebook, some formatting, else some other formatting. Add more if statements if I want to customize other streams.

    Easier to just edit the yaml file.

  • I use those variables elsewhere, hence the "...", they are just snippets from my ludicrously complicated AS page! So don't worry about all that switching round. I could have just done that in 1 line <mt:StreamAction regex_replace="/Richard/","">.

    And in answer to your other q, yes, you would need all those ifs. Benefit of doing it that way is you can upgrade easier and of course any other blogs/authors can set up their own default streams.

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

code.sixapart.com

137 479

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

238 797

Last Topic: Manifest Schema Compatibility Issue When Restoring Blog by Matt on Oct 17, 2012

1858 6594

Last Topic: Categories and Basename Publishing Issues by e21media on Oct 25, 2012

88 307

Last Topic: absolute publish date in Manage Entries screen by .mau. on Apr 18, 2012

1488 5347

Last Topic: Anti-cloning by .mau. on Oct 29, 2012

732 3093

Last Topic: Blog moved server - now users cannot access blog? by mowgs on Oct 30, 2012

89 317

Last Topic: How to "pretify" a url in htaccess with a few wildcards by Caio on May 30, 2012

183 771

Last Topic: Commenting with TypePad by Rob Ferrara on Oct 17, 2012

212 680

Last Topic: Does MT-Approval work in MT5? by DLpres on Sep 25, 2012

27 100

Last Topic: Upgrading MT by Caio on Oct 15, 2012

49 224

Last Topic: Movable Type 6 Ideas by Caio on May 28, 2012

65 248

Last Topic: Expanding new rich text editor and implementing table function by Takeshi Nick Osanai on Jul 30, 2012