I'll briefly explain what I'm trying to do:
I need to sort a set of content-types within a paginated page. Also I need to add filtering to the page, for example each content-type should have a set of tags and the filter needs to filter through these tags.
This is a basic mockup of what this page consists of:
I'm finding it quite hard figuring out the best way to do it, and if this can be done.
Help would be very much appreciated!!
If by tags you mean taxonomy, you just add a taxonomy filter in the view and expose it. What you need to achieve is simple and generic. So a correct answer is ti suggest you go through Views Documentation http://views-help.doc.logrus.com/
Related
I'm trying to figure out a way to render a resource with a specific tpl based on a template variable(tv) value. here is my use case:
I have setup a modx installation for a basic site with a homepage and a blog (I used the articles add-on). I want to display blog posts on the home page, outside of the articles container. From my experience the easiest way to do this is with getResource. However for this specific project I would like to change the tpl of the getResources results based on whatever the tv value is for each result.
The template variable can be looked at as a "post type". if you choose "text" it would have tplA, if you choose "multimedia" it would have tplB etc...
now based on my research you would use the properties 'tplCondition' and 'conditionalTpls' to achieve this in your getResources call, something like this:
[[getResources?
&tplCondition=`tv.blogPostType`
&conditionalTpls=`{"1":"tplA","2":"tplB","3":"tplC"}`
&tpl=`defaultTpl`
]]
The problem is, this does not seem to work with template variables :( it even says it only uses resource fields in the documentation.....which is a REAL bummer, as i have no idea to pull this off otherwise. Based on my limited knowledge, you can maybe create a snippet or something that does this, But i have no clue.
Does anyone have an elegant solution to this problem?
to sum up what im trying to do, again:
-assign a "post type" to blog posts in my articles container via template variable.
-use the template variable value to set a specific tpl based on that value.
any help is highly appreciated. thanks
EDIT: okay I got a reply on the forums and have come across a"solution" to this.
you can accomplish this with css. in the tpl, you do something like:
<article class="[[+tv.post-type]]">....</article>
this will output the post type selected in the tv as the actual element class used, and you can then use css to give the output different looks based on the tv. its actually so simple im a little embarrased i didnt see it before. In my situation it 100% solves my problem, however if you needed to chasnge html im guessing javascript would need to be involved or another method with php. just leaving this here in case someone needs it!
If you need to do major changes to the html you could still probably solve it with css if you have a nice markup. However if thats not enough i would solve it by using one tpl for the getresources call, and letting that tpl handle the switching. If you could have your TV output the value symbolize the name of the tpl that should be used in each case, your tpl would only need this:
[[$[[+tv.yourtv]]]]
Your tv will be evaluated first, and then it will be processed as a chunk. That way you dont need a nasty switch or if-clause.
This is assumin you want toally different tpls, and not just need to change some small part of the standard tpl, in that case you could still use this tecnique though!
Conditional templates seem to work fine with pdoResources (part of pdoTools). (I have to put "tv." in front of the TV in the tplCondition but not in the other TVs)
James is correct.
[[pdoResources?
&includeTVs=`blogPostType`
&tplCondition=`tv.blogPostType`
&conditionalTpls=`{"1":"tplA","2":"tplB","3":"tplC"}`
&tpl=`defaultTpl`
]]
I'd like to achieve the following content structure but no template I know fits it.
Can you advice me from what Template to start modifying? I thought of "Category Blog".
I'm currently planning to integrate the years by adding categories that contain categories with caption/description containig articles I want to be shown completely in this view.
In addition I'd feel grateful to you providing me sources to learn more about how to get the data I need (categories with description, articles with headline and content).
I until now just did CSS adjustments for Joomla based websites and therefore don't know that much about how to actually reviece data from the DB.
PHP and MySQL aren't a problem though.
A bit fuzzy maybe because I don't exactly know where to start but I'm hoping the best.
Thanks a lot :)
I've setup a page with a number of categories and a filter system. However, I'd like users to be able to enter anchors into the URL so that they can simply visit, for example:
www.site.com/page#categoryA
To see simply Category A
This functions quite well, but doesn't allow for multiple anchors. The only solution I've come up with is to keep tacking on the visible categories to the anchor and process the string with jQuery, or is there a better way to do this?
It is also important that when a user clicks beyond this page, hitting the back button presents the categories in their previously chosen visible/invisible states.
This should be possible via hash changes similar to your current approach.
A good way of doing this could look something like this: www.site.com/page/#CategoryA,CategoryB,CategoryC,etc
Or, if you need to use named parameters, you could even do: www.site.com/page/#categories:CategoryA,CategoryB,CategoryC/tags:TagA,TagB,TagC,etc
The jQuery hashchange plugin can handle cross-browser hashchanges for you. A function call to your own code with some basic string parsing / regex checking should take care of the rest and create a nice object from which to read the passed-in values.
If i'm understand you right, you wanna make one page app?
Check here, maybe it is a solution for you http://microjs.com/#spa
What is the best way of implementing multi-level lists/bullets in php?
What I'm trying to implement is a system to take in short phrases, and categorize them within sections. However, at the same time, I would like to have each section to be collapsible and capable of having sub-sections within them.
For Example:
Section 10
Section 10.X
Section 10.X.X
I was thinking of having each sub-layer as an array, but I realize that I've seen the same type of collapsibility in many places, and they all seem to be similar. Maybe there already is a package or library that does this? And if there is, how should my data-structure for keeping each entry be structured?
Your bullets are being done in HTML, as PHP merely generates HTML code. Consider using nested <ul> tags.
The collapsing is most probably going to be javasscript. (Although I wonder if the CSS :active psuedoclass would work in supportive browsers...)
Regarding the package, I'm not sure. You essentially need a recursive list generating function.
For the kind of structure you mentioned, i think you need what is know as Tree View. Check it out on how to implement that.
Screenshot:
Anything to do with toggling, display lists, indenting etc should be achieved relatively easily with HTML/CSS/Javascript.
Inside your category table, you could create a parent_id field which matches to your primary ID. Then run loops to display your TLD as well as another loop to display the categories within the parent.
My view holds a list of nodes ranked by rating (vote-API/Fivestar).
I wish user to hide nodes they do not wish to see in this view. Can this be done?
I'd use flag module. Users flag content (nodes), then you hide it using view filters.
If you want to be really lazy (and future-proof), use taxonomy.
Create a vocabulary called "Visible" and add a "No" term.
Then filter out all the nodes tagged with Visible/No with views.
Always better to use plain language with newb users anyway.
Is it completely arbitrary which nodes they don't want to see? Like they just want to hide an single node they already read on don't care about? If so then there is no easy way that I know of. That would require some sort of custom module that I've never come across.
If it is more predictable and consistent like the user wanting to change the view to only show nodes that are rated 3 or above or 4 or above then you can do that by creating a filter for and exposing it.
Hope that helps.