Jump to content
thetuningspoon

Repository of php Scripts for Templates

Recommended Posts

Not sure if this has already been suggested, but for the less php literate among us it would be great to have some sort of repository of php scripts on the PW website for formatting template data, i.e. the php snippets for outputting different kinds of menus, breadcrumbs, bloglists, etc.

Similar to a database or list of modules, but specifically for the templating side of things, where you don't require a full-on module. Right now you have to scour the forums (or write your own code) if you're looking to do something beyond the basics that are included in the default templates.

  • Like 10

Share this post


Link to post
Share on other sites

I would certainly find this kind of thing helpful.

Along with the scripts could suggest a list of resources for learning some really basic PHP which I am doing at the moment.

Share this post


Link to post
Share on other sites

Good idea. One way to go would be to post those code snippets to Gist (https://gist.github.com/) and build the snippet repo on top of that. They would be tied to github account, so it would nicely show all the modules and snippets build be same author.

  • Like 1

Share this post


Link to post
Share on other sites

Agreed on this. It would be extremely helpful. Maybe in the form of a wiki where everyone could contribute?

Share this post


Link to post
Share on other sites

I think something like what you've linked to there diogo may already be on the cards for the future.

I do really like how they've laid that out over at Symphony so maybe something similar to that would be good - I do like the way I looked at the page and thought "yep, that would be pretty easy to do in PW" and already had myself thinking about the code behind it. Definitely makes a change from other systems I've used where it would be more a case of "I wonder if this is possible?" ;)

  • Like 1

Share this post


Link to post
Share on other sites

Agreed on this. It would be extremely helpful. Maybe in the form of a wiki where everyone could contribute?

I was thinking it would be good if it was something people could contribute to fairly easily. I'm sure that a lot of ProcessWire users here have accomplished a lot of really cool things inside of their templates using the API, and if there were a central place that they could then submit those for the benefit of others, that would save people having to re-invent the wheel or ask on the forums. Which leaves more time for Ryan and others to work on the core and various modules :)

Some kind of basic gatekeeping/moderation would probably be necessary to ensure a minimum quality standard for the scripts.

  • Like 8

Share this post


Link to post
Share on other sites
Some kind of basic gatekeeping/moderation would probably be necessary to ensure a minimum quality standard for the scripts.

I hope this will keep happening, also with modules. These things tend to loose their usefulness when they start being to many and with indistinguishable quality. This is one of the problems with projects that have grown too much.

Share this post


Link to post
Share on other sites

I think it would be great and make sense to have repositories of scripts and modules that are approved by the PW members to ensure they're quality modules. With launching the new PW website we're working on it will come.

  • Like 5

Share this post


Link to post
Share on other sites

I think it would be great and make sense to have repositories of scripts and modules that are approved by the PW members to ensure they're quality modules. With launching the new PW website we're working on it will come.

This would be great. Looking forward to the new site.

Share this post


Link to post
Share on other sites

[Reviving an excellent topic]

I've been trolling around here for a while now.

I have yet to launch a ProcessWire site. But I truly find the support and users here to be among the friendliest around.

A central repository for common and useful snippets would help me and many others new to ProcessWire :)

  • Like 1

Share this post


Link to post
Share on other sites

Surely this is the modules directory? Or am I getting confused?

Share this post


Link to post
Share on other sites

Pete: I think this is something much simpler. Something along these lines:

modules directory = github

snippets directory = gist

  • Like 1

Share this post


Link to post
Share on other sites

Pete: I think this is something much simpler. Something along these lines:

modules directory = github

snippets directory = gist

Ah, now that is perfect because of the API: http://developer.github.com/v3/gists/

Just needs some thought about the code behind it and having users here list their own gists (wouldn't want to get all for a user unless they're relevant).

Share this post


Link to post
Share on other sites

In fact, the functionality for this is simple - allow users to post links to each gist they want to list here, on submit split the gust ID off the end of the URL, check it's accessible (not private) and the sky's the limit :)

Obviously some thought needs to go into categorisation and other relevant fields, but aside from that it's relatively straightforward.

  • Like 1

Share this post


Link to post
Share on other sites

I have sort of started the process by accident in answering a different post

https://github.com/jsanglier/Pw-News

The way I have done these (because it is the way I now tend to work) is to do them as functions that can just be rendered on whatever page.

  • Like 1

Share this post


Link to post
Share on other sites

Just an opposing view but I like writing the code myself. I like writing it over and over each time I need it. I like researching how to do a certain task by going through the threads here and I don't mind asking for help every once in a while, not to have the solution handed to me, but just to get a hint, point me in the right direction kind of thing. The fine members here are happy to provide code samples and snippets that I analyze before using and I find the generosity astounding.

I like doing it myself because with each repetition it becomes easier, I understand it more. If I could scroll through a pre-made selection of code snippets and only had to copy and paste, I don't think I'd learn very much.

A repository of code snippets is a good time saving idea for when I am a PHP expert and know it backwards and forwards but as long as I'm still a novice and trying to learn, I think I'll do it the hard way.

Share this post


Link to post
Share on other sites

Digitex

I am with you there.

However, as soon as I find a really good solution, I am trying to store it as a reusable something, even if it only a reference. 

If I am feeling sensible, I even remember to comment it so I know what it is.

I do this with music too. I am a professional composer, but if I come up with a really nice brass arrangement, I often store it separately - I wont use it again exactly as it is, but it is really helpful if I am looking for a particular sound.

  • Like 1

Share this post


Link to post
Share on other sites

Digitex

I am with you there.

However, as soon as I find a really good solution, I am trying to store it as a reusable something, even if it only a reference. 

If I am feeling sensible, I even remember to comment it so I know what it is.

I do this with music too. I am a professional composer, but if I come up with a really nice brass arrangement, I often store it separately - I wont use it again exactly as it is, but it is really helpful if I am looking for a particular sound.

I get you Joss. My thoughts were directed at the OP where everfreecreative was saying it would be good for the less PHP literate. I think it would be very useful for the PHP pros as a time saving tool. Any novice such as myself, who wants to learn, not so much.

To me it's sort of like allowing calculators in schools. Once you know how to do mathematics in your head or on paper then a calculator is a handy time saving device but if you use it in place of those skills you'll likely never learn them. Why do long division on paper when a few button pushes on a calculator gets you the answer.

Still a good idea for those that want to use it, no judgement on my part, I'm just pointing out that if you want to learn, it may not help you do that.

  • Like 1

Share this post


Link to post
Share on other sites

Following the thread here, it is hard to say that what PW solution you got to work on your site would help others. Every problem or site design is going to be different. And every developer is going to tackle that solution differently.

That being said it could be helpful to have such a repository for those new to PW and need some helpful steps to create a menu, image slideshow, members section or whatever else is pretty standard in sites these days.

I welcome the idea.

Share this post


Link to post
Share on other sites

it would be cool if there were a searchable and tagged repository of PW code snippets;

each code sample could include the commented code, tags (like menu, gallery, user, forms, search etc.) and maybe a description field where you could put in what the context was.

i'm always bringing up previous sites that I solved a problem on to see what the code I used was, and then copying/modding it to the new project..

edit: i just installed CodeBox and looks good. can also send snippets to gist

  • Like 1

Share this post


Link to post
Share on other sites

I just wanted to add my vote for this functionality. Seems like it might be a fairly easy modification, or perhaps addition to the code that runs the modules directory. Of course it would also be awesome to also be able to browse these snippets through the PW admin like the modules manager.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...