Skip to content
General Revolution Evolution Add-ons International
Login | Register | MODX.com
MODX Open Source Content Management System, Framework, Platform and More.
Find a Partner | Hosts + SaaS | Jobs | Donate
  • RegisterSign Up with the MODX Community
  • LoginUse Your MODX.com Account
  • MODX Community Forums
  • Add-ons
  • Module, Plugin & Snippet Usage
  •  
  • [snippet] ShowSnippet. Show the contents of a snippet as html.#

  • 19986
    90
    Stephan Dale
    http://f3internet.com/search/by-tag?tag=modx
    http://mindspill.net/computing/cross-platform-notes/modx.html

    modx@mindspill.net Reply #1, 6 years ago

    Reply
    • Link to this post#1
    Hi all.

    I've written a snippet which outputs the contents of another snippet as html. I use it on my site to display the snippets I've written or modified. http://mindspill.net/computing/cross-platform-notes/modx.html
    Steph


  • 10487
    1,448
    Search | Download Latest Release | General Support
    About MODx | Documentation | Bugs/Wishlist | FORUM RULES

    Garry Nutting www.modx360 | My Amazon Wishlist | XBOX 360 Gamertag: webnerd

    garryn Reply #2, 6 years ago

    Reply
    • Link to this post#2
    Nice snippet!
    That'll save me a bit of time copying and pasting ...

    Cheers, Garry


  • 22303
    9,586
    - MODX Chief Architect

    Jason Coward | MODX Chief Architect

    jasoncoward.com | @drumshaman

    opengeek Reply #3, 6 years ago

    Reply
    • Link to this post#3
    BTW guys, to do this, there is already a built in API function; no extra snippet required!

    $snippetName= 'MySnippet';
    $snippetParams= array('param1'=> 'value1, 'param2'=> 'value2',);
    $html= $modx->runSnippet($snippetName, $snippetParams);


    Not sure why this is not included in the online API documentation, but I'll get that taken care of this weekend.

    Let me know if you have any questions on usage.


  • 32241
    1,495
    Wendy Novianto
    PT DJAMOER Technology Media
    Xituz Media

    wendy Reply #4, 6 years ago

    Reply
    • Link to this post#4
    I thought that this snippet only showing the code in plain text, instead of running them, am I getting this whole discussion right or what?

    Sorry, I might not get the whole discussion in here.


  • 28042
    14,561
    How MODx Evo WorksLog in to an Evo Manager username guest, password guestuser.

    sottwell Reply #5, 6 years ago

    Reply
    • Link to this post#5
    It doesn't run the snippet, it just outputs the snippet's source code as plain text.


  • 22303
    9,586
    - MODX Chief Architect

    Jason Coward | MODX Chief Architect

    jasoncoward.com | @drumshaman

    opengeek Reply #6, 6 years ago

    Reply
    • Link to this post#6
    Sorry guys, I didn't realize this when I read it the first time. Thanks for the clarification.


  • 32241
    1,495
    Wendy Novianto
    PT DJAMOER Technology Media
    Xituz Media

    wendy Reply #7, 6 years ago

    Reply
    • Link to this post#7
    Quote from: OpenGeek at Jan 29, 2006, 03:27 AM
    Sorry guys, I didn't realize this when I read it the first time. Thanks for the clarification.

    lol, Jason, I think you just did way too much programming lately. Time to take a break for a while


  • 18397
    3,250
    Documentation TRAC (Bugtracker) Forum How to get help
    User Wiki Credits SVN Server Ditto HQ
    Stable Download Development Download

    MARKSVIRTUALDESK Reply #8, 6 years ago

    Reply
    • Link to this post#8
    I believe there is an Etomite snippet that does this with syntax highlighting, etc.


  • 19986
    90
    Stephan Dale
    http://f3internet.com/search/by-tag?tag=modx
    http://mindspill.net/computing/cross-platform-notes/modx.html

    modx@mindspill.net Reply #9, 6 years ago

    Reply
    • Link to this post#9
    Hi.

    I've found the etomite snippet. It's called DisplayCode and it's on the second page of their miscelaneous snippets... http://www.etomite.org/browsesnippets.html?int_page=2&lst_category=10 (I didn't link directly to the snippet because I don't think it's allowed). Ok, that's not allowed either!

    I tried it but got a lot of odd characters that couldn't be interpreted by the browser and "Warning: Unexpected character in input" warning messages. Also, some characters, like < and >, aren't encoded into html so the doc is still being interpreted as php (hence the warning messages).

    Test page here: http://mindspill.net/computing/cross-platform-notes/displaycode-snippet-test.html
    If anyone gets it working (or if I'm using it in the wrong way) please let me know.

    Steph


  • 28471
    48

    stempy Reply #10, 5 years, 11 months ago

    Reply
    • Link to this post#10
    Updated this slightly to use php's syntax colour highlighting.

    Added optional &noHighlight parameter to just display normal html output.





Actions

Login to Post

Other Support Options

To file a bug or make a feature request visit our issue tracker, or you can also purchase commercial support.

Love MODX?

If you build sites for a living with MODX or just love using it, why not give back?

Information

Posted in this thread:
MARKSVIRTUALDESK, garryn, modx@mindspill.net, opengeek, sottwell, stempy, wendy

 
Back to Top

MODX Global HQ

1333 N Stemmons Fwy, Ste 110
Dallas, TX 75207
United States

+1 (469) 777-MODX (6639)

The MODX Company

  • Contact
  • Media Center
  • Work at MODX
  • Wall of Fame
  • The MODX Blog

Sponsors

SoftLayer Firehost: Secure Cloud Hosting

Stay Connected

Read our previous email newsletters.

Twitter Facebook Google+ LinkedIn github Feeds

Privacy Policy | Terms of Service | Pixels by AKTA Web Studio© 2005-2012 MODX. All rights reserved. Trademark Policy