We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44601
    • 18 Posts
    Hello everyone,

    I'm hoping someone can give me suggestions on the best way to handle data for my website. The website is designed to meet the needs of people who share my very rare health condition and right now I am trying to design a doctor list. Currently I have to hand code all of the HTML for the list which isn't a practical to keep it updated. The example I have is:

    http://masto.travelerstavern.com/index.php?id=4

    Its not fancy, but it works and I will resign the CSS later.

    The Question: What is the best way to store and retrieve the data so it is dynamically generated? I would like to create an admin page that would allow me to type in the information, save, and edit the information later. If I can get an example of the code for one working textBox to enter data I can do the rest. Of course I would need a page to retrieve the data and display it.

    More Details:

    1) I'm estimating that right now I will have 30 entries (Doctors) but it could grow to hundreds as I expand it worldwide.

    2) I would like the doctor list to be in <LI> tags so I can easily alter to look with CSS. (Unless there is a better/easier way of doing it)

    3) I'm not looking for anyone to write it for me. I just need someone to explain the best way to handle this so I can stop researching ways that I find out won't helpful hours or days of wasted time later. If someone could write an example for me that I can expand on I would be extremely grateful, and I can pay them on Odesk or via Paypal.

    4) I know HTML / CSS but I'm still learning JS and I'll be starting with PHP soon.

    Thank you for your help everyone!
      Be well!
      • 3749
      • 24,544 Posts
      Here are a couple of questions that will be important for the data design. First, can everything you need be represented by a single record for each Doctor with fields for everything you need to store about that Doctor? Second, will users be searching for doctors by things other than name (e.g. location, specialty, medical group, etc).

      I think the answer to the first question is probably yes. If the answer to the second one is no, the answer is pretty easy:

      - Create a resource for each doctor. Make them all children of a resource called Doctors (let's say its ID is 12). Use the fields of the resource for as much information as you can, e.g.,

      pagetitle: Doctor's last name
      longtitle: Doctor's full name
      etc.

      - Create Template Variables for any data that won't fit in the standard resource fields.

      - Create a separate Template for the individual Doctor pages laid out you however you want, with placeholder tags for the info.

      - Use the Create/Edit resource panel in the Manager to add new doctors and edit existing ones.

      - Use getResources or pdoResources to display your list of doctors, with links to their full page. This is done with a Tpl chunk (let's call it DoctorRowTpl) that contains the HTML to display one doctor with placeholder tags for the doctor's info. Something like this:

      <li><span class="name"> [[+longtitle]]</span> <a href="[[~[[+id]]]]">Read More . . .</a></li>


      The tag to display all the doctors would look like this (and could go on the Doctors page - the parent of the individual doctor pages):

      [[getResources? &parents=`12` &tpl=`DoctorRowTpl`]]


      If users will need to search by data that's stored in the TVs, you can still use this strategy, but searches may get a little slow when you have a lot of doctors.












        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 44601
        • 18 Posts
        Bobray,

        Thank you for the reply! I think I follow the main jist of your answer, but I'm am having to go back and read up on some of the details you provided to make it all flow in my head. Hopefully I'll be able to fully understand it here in the next few hours.

        In the future I would like users to be able to search the doctors by any of the information provided (e.g. location, specialty, medical group, etc) but right now I just want to get something running so people can use it and I can learn.
          Be well!
          • 44601
          • 18 Posts
          Ive been reading up and I believe I understand what you mean on your previous post, but that wouldn't allow me to input information on a standard web form.

          Any suggestions on creating a page that would allow me to enter the data?
            Be well!
            • 3749
            • 24,544 Posts
            In that case, you might want to consider using ClassExtender to add the extra resource fields for you and not use TVs at all for the data. It's not nearly as difficult as it sounds at first, and you can do *very* fast searches no matter how many doctors you have. ClassExtender adds the extra fields to the Create/Edit Resource form, and once it's set up, you can forget about it.

            Once you've designated the extra fields and run ClassExtender, everything else is same as above except that instead of getResources, you'd use getExtResources. It's actually quicker than doing what I suggested above since you don't have to create and connect all the Template Variables. You also don't have to re-purpose the regular resource fields.

            The reason I suggest this is that it's really tedious and error-prone to move existing data from Template Variables to a custom table after the fact. Template Variables were never meant as a data storage system and they don't work at all well for that. Searching by them is quite a pain.

            More info:

            http://bobsguides.com/blog.html/2014/06/02/why-extend-modresource/

            http://bobsguides.com/classextender-class.html
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 44601
              • 18 Posts
              If I implemented this how would I create the admin page where I enter new doctor information?
                Be well!
                • 3749
                • 24,544 Posts
                You'd still create a new doctor by just creating a new resource in the Manager and filling in the fields. You could also edit existing doctors there.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 44601
                  • 18 Posts
                  I'm going to read up on this extra. Thank you for your help!
                    Be well!
                    • 3749
                    • 24,544 Posts
                    If you run into trouble, just ask. smiley
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting