
kavrick
User
Mar 4, 2007, 12:44 PM
Post #6 of 9
(2705 views)
Shortcut
|
|
Re: [TF Solutions] Mutilple article edit views by category.
[In reply to]
|
Can't Post
|
|
Tim - Sorry for the wait on this. I meant to get back to you sooner. Also, this might take a while to explain, so bear with me... A couple of notes first. The modifications I made, could really screw up your system. Be sure to back-up everything first... And, I have no idea how some of these changes might affect you ability to get support. Everybody here seems pretty friendly, but I would consider this like peeling the "Warranty Void if Removed" sticker on the back any device! :) There are basically 4 parts to this. First, go into the Database Editor and change the "categoryNum" field type to "textfield". It should already be stored as an integer. Second you need to create some "field hiders"... At least that's what I call them... These are basically blank fields which hide / show the fields between them based on the category. Here's an example. Start Hider... <!-- templateIf : $categoryNum$ ne "19" --> <tr><td colspan="2"> <table style="display: none;"> <!-- /templateIf --> End Hider... <!-- templateIf : $categoryNum$ ne "19" --> </table> </td></tr> <!-- /templateIf --> You create these "hiders" by creating a new field, adding a label and name, but don't select a field type. Leave it as none. Then copy one of the "hiders" above into the HTML section of the field separator (down at the bottom) and check HTML. You have to have a "hider" start and end... and you'll see that these basically just hide / show any fields in between them based on the category. I read about this in a tutorial, but can't remember where it is right now. You can see the TemplateIF statement is really straightforward. If the category doesn't equal 19, it hides these fields. If it does, then it shows them. A couple of caveats here which I ran into immediately, this is really just hiding the fields from view so if you're doing some validation on them, you'll run into trouble. Having the fields in between the "hiders" required, means that the system will throw them a "required" message when the user can't even see the fields. I worked around it by not having any required fields, but if that's something you need, then this might not be for you. The last part was the simple part. You'll notice that you can pass some field values to the add article page through the URL. For example, if you tack on the category number to the default "add article" link on the homepage (like this admin.cgi?action=articleAdd&categoryNum=19) the category number will be pre-filled on the article page... and if you've got some "hiders" in place, the fields in between them will be shown / hidden based on that category number. The final thing I did was to alter the actual admin templates so I could present users with the choices of what type of content they wanted to add. For me, it was adding a simple drop-down menu to both the homepage and the articles page. This menu is nothing more than a link which directs them to the add article URL but with different category numbers on the end. At that point, you've given users the ability to add different types of content and only show the relevant fields required for that content. Make sense? Here's a few remaining notes that will be helpful. Any fields that aren't contained within a "hider" will be show... So, I always move the "Status" field to the end, outside of a "hider" so it will always be there. I created a generic "hider" to always hide the categoryNum field. This way it won't get screwed up. I did this by using a <!-- templateIf : $categoryNum$ ne "0" --> for both the start and end "hiders". You can stick the Filename field in there too... Even though that field is hidden, the javascript will populate it. I also learned through all of this that you can use the templateIF statements in the admin menus themselves. You can do stuff like hide the "erase" button unless they have admin privileges etc. I was able to create some really customized menus for my clients... Oh, I almost forgot, one way you can get around having required fields is by adding a default value to the field. That way there something in it, even though the user can't see it. Anyway, let me know if you have any questions. I've done some pretty major tweaking to all of my installs. I'll do my best to help. David
|