Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Sortable columns in app's admin view

edited March 2013 in Apps

I coded my app's admin handler and view to allow users to click on the column titles to sort each ascending or descending. It works fine, but their selections weren't getting passed to the next/previous page, so I added

if (isset ($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"]) $o->url .= '?'.$_SERVER["QUERY_STRING"];

immediately after line 60 of navigation/handlers/pager.php ($o->url = str_replace ('&', '&', $data['url']); // the url format for building pager links)

I notice that the 'text' pagination style is hard-coded to say 'Older results' and 'Newer results', but those aren't accurate once you're letting the user sort.


  • If you'd like to submit a change like this to be included in Elefant, a quick way of doing that with small changes is to find the file on Github (e.g., apps/navigation/handlers/pager.php and click on the Edit button in the top right of the source view.

    That will automatically create a fork of the project on Github, allow you to edit the file right inside the browser. Afterwards, you would make a "pull request", which submits the change back to the main project for review :)

  • I'll do it. Do you have a convention about one line if statements? ie

    if ($condition) action;


    if ($condition) {
  • I typically use braces, but I was using a one-liner today in my latest mini-project:

    // Authorize user
    if (! saasy\App::authorize ($page, $tpl)) return;

    IMO just makes more sense in some cases :)

  • OK, done. Now that I forked it, do I do something like git clone in my local elefant installation so that I can use git to upload any tweaks from the command line?

  • That's the idea :) You can work on new features on your fork, and at any time pull new changes from the main repository, or make a pull request to submit changes from yours to the main repository.

    Once you get the hang of git, it really makes it so much easier to collaborate, but it sure isn't the easiest thing to get started with... haha

  • Thanks for the help. Specifically, I'm wondering how to get from where I am currently to where I ought/want to be. Where I am currently: I installed elefant via git from the command line, but I didn't fork it or create a repository at that time. I installed the apps I'm using (sitemap.xml, assetic) by downloading zip files, unzipping, and copying to the elefant directory.

    Would it make sense to tell git that my forked branch is the new master?

    For the apps, I guess the thing to do is reinstall using git? And then diff the files to find any changes I had made? I don't think I had made any to anything other than the filemanager embedded gallery and the navigation handler, but it wouldn't hurt to check.

  • It's probably best to start with a new clone of your forked repository and work in that. Definitely diff the two to make sure you aren't accidentally throwing away changes you've made. And I recommend using git clone for apps too, so you can manage changes to them with git as well.

  • Thanks. A lot of the folders in apps/ come with the main elefant install, right? (filemanager, etc.)

  • Quite a few, yeah. You can think of Elefant as a PHP framework with a bunch of pre-installed apps that form the CMS.

  • OK, so if I start over and git clone my forked repository, sitemap.xml, and assetic, should I also git clone my properties app? Or should I just copy or move that from my current install? I followed the steps you outlined in your blog post.

  • If you ran git init or cloned your properties app before, you can just copy it over and it'll work fine already. I do recommend using git for your own apps too, and pushing to Github or another remote repository gives you a backup too.

    For private repositories, BitBucket offers free hosting like Github does for open source ones. It's not quite as nice, but works just fine for hosting private projects for free :)

  • OK, I git cloned my fork of elefant in an empty directory, then diffed and manually updated the files there from my previous working directory. However, when I navigate to the new directory in a browser, elefant wants to run the installer. How do I tell it that it's already installed? Or is it safe to let the installer run?

  • The installer will create a blank file named conf/installed to mark that it's been run. If you manually create that file it'll have the same effect of stopping the installer.

  • Thanks, that works. The problem now is that I can't login. I'm using sqlite. I copied over site.db, but I get "Incorrect email or password, please try again."

    I have the previous install running as a separate virtualhost, and I can log in there without issue.

  • One thing to check is that the database prefix setting is the same. If it's coming from an older install, you may need to set a blank prefix. That's tripped me up before.

  • I think it is. At least, conf/site.db and conf/config.php are identical both places.

    Update: figured it out. The web user didn't have write permissions to conf/

Sign In or Register to comment.