Soldiers |
Documentation for Tributes and Prayers Export Script
PHP Script
This PHP script exports tributes and prayers (comments) from a MySQL database into JSON files. It provides two main functionalities:
- Export tributes to a JSON file.
- Export prayers to a JSON file.
Fields in the Tributes JSON File
The tributes JSON file contains the following fields:
- id:
- Description: Unique identifier for each tribute.
- Type: Integer
- userid:
- Description: ID of the user who created the tribute.
- Type: String
- LUID:
- Description: Legacy Unique Identifier for the tribute.
- Type: String
- category:
- Description: Category ID of the tribute, which can be used to categorize the tribute.
- Type: String
- title:
- Description: Title of the tribute.
- Type: String
- profile:
- Description: Detailed profile or content of the tribute, typically in HTML format.
- Type: String
- city:
- Description: City related to the tribute.
- Type: String
- state:
- Description: State related to the tribute.
- Type: String
- zip:
- Description: ZIP code related to the tribute.
- Type: String
- tribute_image:
- Description: Filename or URL of the image associated with the tribute.
- Type: String
- latitude:
- Description: Latitude coordinate for the location related to the tribute.
- Type: String
- longitude:
- Description: Longitude coordinate for the location related to the tribute.
- Type: String
- startdate:
- Description: Date when the tribute was created or started.
- Type: String (formatted date)
- age:
- Description: Age of the person or entity the tribute is for.
- Type: String
- occupation:
- Description: Occupation of the person or entity the tribute is for.
- Type: String
- incident:
- Description: Description of the incident related to the tribute.
- Type: String
Fields in the Prayers JSON File
The prayers JSON file contains the following fields:
- no_comment:
- Description: Unique identifier for each prayer (comment).
- Type: Integer
- id_ads:
- Description: ID of the tribute the prayer is associated with.
- Type: String
- commentby:
- Description: ID of the user who made the comment.
- Type: String
- subject:
- Description: Subject of the prayer (comment).
- Type: String
- comment:
- Description: Content of the prayer (comment), typically in HTML format.
- Type: String
- date:
- Description: Date when the comment was made.
- Type: String (formatted date)
Roadmap for Managing Smaller JSON Files for Tributes and Prayers
Phase 1: Initial Setup and File Creation
- Create Index JSON File:
- Objective: Generate an index file with basic information for all tributes.
- Steps:
- Read the existing
tributes.json
andprayers.json
files. - Combine tributes and their respective prayers.
- Create smaller JSON files for each tribute, including their prayers.
- Generate an
index.json
file with basic tribute details and prayer counts.
- Read the existing
- Script for Splitting JSON Files:
- Objective: Create a PHP script to split the large JSON files into smaller, individual tribute files.
- Steps:
- Read the
tributes.json
andprayers.json
files. - Group prayers by tribute ID.
- Create a JSON file for each tribute, containing both tribute details and prayers.
- Save these files in a
tributes
directory.
- Read the
Phase 2: Display and Load Tributes Dynamically
- Update the Tribute Listing Page:
- Objective: Modify the tribute listing page to load data from the
index.json
file. - Steps:
- Load the
index.json
file using AJAX. - Display the list of tributes based on the data in the
index.json
file. - Implement infinite scroll or pagination for better performance.
- Load the
- Objective: Modify the tribute listing page to load data from the
- Load Tribute Details on Demand:
- Objective: Fetch and display detailed tribute information dynamically.
- Steps:
- Add event listeners for user interactions (e.g., clicking on a tribute).
- Load the respective JSON file for the selected tribute using AJAX.
- Display the detailed information, including prayers.
Phase 3: Implement Editing Functionality
- Create an Edit Form:
- Objective: Develop a web form to edit tribute details and prayers.
- Steps:
- Create a PHP page with a form to load and edit tribute details.
- Fetch and display the tribute data based on the provided
LUID
. - Allow editing of tribute details and prayers.
- Include JavaScript to dynamically add and remove prayer fields.
- Handle Form Submissions:
- Objective: Save the updated tribute details and prayers back to the JSON file.
- Steps:
- Process the form submission using PHP.
- Update the respective JSON file with the new data.
- Provide feedback to the user (e.g., success or error messages).
Phase 4: Enhancements and Optimization
- Optimize Data Loading:
- Objective: Ensure efficient data loading and updating processes.
- Steps:
- Implement caching mechanisms to reduce server load.
- Optimize AJAX requests for better performance.
- Ensure proper error handling and fallback mechanisms.
- Security and Validation:
- Objective: Enhance the security and validation of data handling processes.
- Steps:
- Implement input validation for the edit form.
- Ensure proper sanitization of user inputs.
- Implement authentication and authorization mechanisms if necessary.