Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor Jason

    (@verysimple)

    Hmm, I think at the moment you could probably do it with some Javascript code. HungryFEED has an {{index}} tag that you can put into your template and use as ids for the div tags, then code using those.

    Not exactly out-of-the-box, but I think it would be feasible.

    Thread Starter HFman

    (@hfman)

    That’ll be great if that is integrated.
    Also one more request is that when displaying news feeds from one specific source, i’d like to insert the news provider’s name and link on top or bottom of each rss result. Perhaps the shortcode itself can also pass a couple of more variables to the templates. One or two variable(s) perhaps for plain text, and another one or two variables for html-links to those texts.

    Plugin Contributor Jason

    (@verysimple)

    putting feed-level variables into the template would be pretty easy, i’ll do that in the next release.

    i doubt that I’ll integrate adsense or any specific service since that would lead to having to support thousands of plugins and services, but what I’ve been thinking about doing is integrating support for “mustache” template engine, that way you can create all kinds of logic and such in the templates to use whatever service you want

    Thread Starter HFman

    (@hfman)

    That’s great – thanks.

    And thank you for your prompt response.

    As for the code injection; ‘mustache’ looks interesting and seems to be the answer. OR if HF provides a new variable to set interval for injection, then perhaps a second varibale perhaps can pass a shortcode to the template – and the shortcode will holed the code for adsense or whatever. so for example every 3 or 2 or.. results the shortcode passes external code into the template through HF. That maybe easy also, except for setting up the logic for the interval perhaps – you know best. I’m using ‘Shortcodes’ plugin with HF right now for a different purpose. In http://www.youthumbs.com/most-recent-headlines/ i’m using HF to pull all feeds. The categorized results section, is HF used within a shortcode plug.

    Plugin Contributor Jason

    (@verysimple)

    ok, in version 1.5.7 there’s an option to enable shortcodes in templates on the hungryfeed settings page.

    also Mustache is implemented and you can do conditional logic using code like this, you can also put shortcodes inside these blocks:

    {{#index_3}}
      everything inside this block only appears on item #3
    {{/index_3}}
    
    {{#index_6}}
      everything inside this block only appears on item #6
    {{/index_6}}
    Plugin Contributor Jason

    (@verysimple)

    oh, also feed_title and feed_description are now available as template variables

    Thread Starter HFman

    (@hfman)

    Hi,
    The new addition does very much close to what I need – THANKS SO MUCH!
    You can see it at http://www.youthumbs.com/headlines-sweep/
    I have attached a URL to the feed_title at the bottom of each feed.

    Is there a way to activate and deactivate it throught the HF shortcode? Since we are limited to 3 templates, an on/off switch would help to only display the feed_title for certain needed feeds, on a multi-feed page.

    I’ll expriment with the shortcode and mustach implamentations.

    Do you think you’ll be adding the two additional variables to HF shortcode so we can pass our own text, and URL to templates? This way we pass any text (for example ‘CNN’) and url (e.g. “http://www.cnn.com”) to the template from HF shortcode.

    Great improvements to an already great plugin.

    Thanks again!

    Plugin Contributor Jason

    (@verysimple)

    good idea. that’s easy – i’ll add that to the next version. you can enable that right now by adding the following to hungryfeed.php line 366:

    $rss_values = array_merge($params,$rss_values);

    that’ll make shortcode parameters pass-through to the templates.

    that’ll actually allow you to add your own template logic that you can turn on/off with your own shortcode parameters

    Thread Starter HFman

    (@hfman)

    Tested it – That works PERFECT!!!
    The way you are coding is very cool since now we can name our own variable(s), and perhaps as many as we want?, in the HF shortcode.
    After adding line 366, got it to work by adding two new variables my_text and my_text_url to HF shortcode; first one holding a text value and the other holding the URL. I also add the corresponding place holders {{my_text}} and {{my_text_url}} to the template.
    Results are at http://www.youthumbs.com/headlines-sweep what now shows up at the bottom are resulats from the new variables instead of the previous feed_title variables.

    I’m sure I’ll bug you again with other request. There is just so much potential for this plugin.

    THANKS A MILLION!

    Plugin Contributor Jason

    (@verysimple)

    cool, glad it works. your passthrough idea is actually really cool because it can be used to create virtually unlimited template varieties by doing something like this in, for example, template 1:

    {{#option_a}}
       ... option a code here
    {{/option_a}}
    {{#option_b}}
       ... option b code here
    {{/option_b}}
    {{#option_c}}
       ... option c code here
    {{/option_c}}

    then in your shortcode you can specify a template like this

    [hungryfeed url="..." template="1" option_a="true"]

    Thread Starter HFman

    (@hfman)

    Your integration of mustach into the plugin was a very good move.
    Based on your example its possible now to make different versions of a signle template just by creating quick-variables and switchig’em on/off from the HF shortcode.

    I just wonder what would happen to the execution speed if too many conditions are used in a template.

    I’ll be puting that use for certain.

    Thanks much!

    Plugin Contributor Jason

    (@verysimple)

    that’s a good question, i’d be curious to know myself. It does run for each item in your feed, so the template generator usually runs 10 times because that’s the typical number of items in a feed.

    I have a feeling the overhead is not really that great. If you were to make an enormous template it might eventually cause php “memory limit exceeded” errors. I’d be surprised to see that, but my guess is that’s the first bottleneck.

    Mustache could be improved by “preparing” the templates and then doing less work each time you render the same template. So that would be a good place to look for optimization.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: HungryFEED] Code Injection’ is closed to new replies.