Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Image Path Function?

Hi There,

I'm just starting on my first theme in Vanilla, however as it's for a client, I don't have a great deal of time at my disposal to trawl through the core files and addons for some of the answers I seek, so I was just wondering if there is a templating tag that returns the current selected theme path, something akin in order to make echoing images a bit better? It feels a bit clumsy just hardcoding paths to the images folder...

(Also if anyone else can shout some other useful functions or templating tags I won't complain either! The docs haven't been particularly helpful thus far)

Thanks in advance,
SudoCat

Comments

  • x00x00 MVP
    edited July 2014

    what context?

    check out library/core/functions.general.php and library/core/functions.render.php

    Asset will get you the path to an asset, SmartAsset is a smarter version. Url can get you paths. Img is used to rendering images and with take the relative path from the forum root so there is no need to pass Url or Asset or SmartAsset as it uses the later internally, unless some good reason.

    grep is your friend.

  • Context for this instance was adding in images to the menu items (to use the universal header for the rest of the website), but I imagine there will be lots of cases of needing custom images.

    Thanks a lot, should give me a good start. What exactly defines an asset? I've noticed them spoken of vaguely in the docs, but there isn't a great deal of details from what I've seen.

  • x00x00 MVP
    edited July 2014

    So the context is the theme default master? if it is a smarty tpl, you need to use the smarty equivalent.

    Asset equal static content that served directly. images, js, css, etc

    However you would mostly use it for images. It very un-Vanilla echo out styles and js file directly. You would quene them up.

    grep is your friend.

  • Right, I wasn't sure as from what I've seen within the smarty templates, the asset tag is used for pulling in blocks of content, so I wasn't quite sure how to use it for images and such. And thank god for that, scripts & styles should always be queued! Will need to look into doing that next :smile:

    Ohh, also another quick thing that just popped up if you don't mind helping again, but how would I go about doing conditional statements for things such as checking if the user is logged in?

  • R_JR_J Admin

    If you are interested in themeing, you might be interested in the contents of that folder: /library/vendors/SmartyPlugins

    Nevertheless you will have to create Smarty snippets by yourself and you should place them in your own theme folder: http://vanillaforums.org/discussion/comment/211052/#Comment_211052

  • @SudoCat said:
    how would I go about doing conditional statements for things such as checking if the user is logged in?

    Check out the community wiki on smarty theming for some common examples: http://vanillawiki.homebrewforums.net/index.php/Using_Smarty_with_Vanilla#Other_Tags

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Thanks a lot guys, this has given me a huge help in getting started, the vanilla wiki @hgtonight‌ posted looks especially helpful! Thanks again.

  • Hi everyone, sorry to bump an old thread, but I've been reading through a lot more about developing for Vanilla, and I've been wondering what the best method to achieve what I'm meant to be doing here actually is.

    I have been reading through this thread, and I noted one of @hgtonight‌'s comments in there:

    Themes change the way your site looks. Locales change the wording of text. Plugins add functionality. Applications can do all three.

    Now then for the site I am making, I will probably end up needing some additional functionality - even if just to help develop a slightly more advanced layout. I was hoping that there would be a file for the theme which could be used for adding PHP (Much like WordPress's functions.php in themes), however that search drew up a blank. I was then considering the possibility of creating a theme with a corresponding plugin, however this quote seems to suggest to me that perhaps an application is the thing I should be using for the most optimal control - I'm just not sure if this would be overkill, or if this would even enable me to accurately theme the other applications.

    I hope that makes sense, would love to know what's the best option - to me, it still seems probably theme+plugin - but possibly just because doing a whole application sounds terrifying! haha

    Thanks again for all the help, and for any more to come! :D:3

  • hgtonighthgtonight MVP
    edited July 2014

    @SudoCat said:
    ...needing some additional functionality - even if just to help develop a slightly more advanced layout. I was hoping that there would be a file for the theme which could be used for adding PHP (Much like WordPress's functions.php in themes), however that search drew up a blank.

    You are looking for the term Theme Hooks. This is essentially a plugin that is bundled with a theme. It is only active when the theme is. It offers almost all of the functionality of a standard plugin (just missing out on some helper methods).

    Official Docs: Theming Hooks

    Community Wiki: Theme Hooks

    EDIT - I just realized the docs are pretty bare on this subject. You need to add your themehooks file to your theme's base folder. A sample file is in the wiki.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Absolutely fantastic, although yes the official docks are rather sparse still at the moment.

    Does this page accurately cover all the different hooks?

    Thanks again for the help; I don't think I've ever had the pleasure of encountering such a helpful community :smile:

  • Looks like a pretty good representation of the hooks, but I doubt it is completely up to date.

    I find Eventi to be helpful to quickly find fired events. It hooks into every event and spits out some information that describes the event on the page.

    Other than that, searching the codebase for 'FireEvent' will also come up good information.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.