Frontend helper

The frontend_helper.php file in the CMS provides helper functions for handling URLs and formatting data for the frontend. These functions facilitate the creation of dynamic URLs, number conversions, debugging data, and API URL construction.


base_url()

  • Purpose: Returns the base URL of the application, including the language.

  • Parameters:

    • $path (string): Additional path to append to base_url.

  • Usage:

    echo base_url();
    // Output: https://your_domain//
    
    echo base_url('dashboard'); 
    // Output: https://your_domain/dashboard

public_url()

  • Purpose: Returns the URL of the public directory in the application.

  • Parameters:

    • $path (string): File or folder path inside public.

  • Usage:

echo public_url(); 
// Output: https://your_domain/

echo public_url('dashboard'); 
// Output: https://your_domain/dashboard

history_post_url()

  • Purpose: Returns the URL for the user's viewed post history.

  • Parameters:

    • $posttype (string): Type of post.

  • Usage:


api_rating()

  • Purpose: Returns the API URL for rating a post.

  • Parameters:

    • $posttype (string): Type of post.

    • $id (int): Post ID.

  • Usage:

api_count_view()

  • Purpose: Returns the API URL to increment the view count of a post.

  • Parameters:

    • $posttype (string): Type of post.

    • $id (int): Post ID.

  • Usage:

api_like_post()

  • Purpose: Returns the API URL to like a post.

  • Parameters:

    • $posttype (string): Type of post.

    • $id (int): Post ID.

  • Usage:


update_lang_url()

  • Purpose: Updates the language in the current URL. Used for use in language switching links.

  • Parameters:

    • $new_lang (string): New language (e.g., en, vi).

    • $new_slug (string): New slug.

  • Usage:


auth_url()

  • Purpose: Returns the URL for user authentication.

  • Parameters:

    • $path (string, optional): Additional path.

    • $lang (string, optional, default=LANG): Language identifier.

  • Usage:


cat_url()

  • Purpose: Returns the URL for a post category.

  • Parameters:

    • $slug (string): The slug (short URL) of the post category.

    • $posttype (string): The type of post (post type).

  • Usage:


page_url()

  • Purpose: Returns the URL for a specific page.

  • Parameters:

    • $slug (string): The slug (short URL) of the post category.

    • $posttype (string): The type of post (post type).

  • Usage:


single_url()

  • Purpose: Returns the URL for a single post.

  • Parameters:

    • $slug (string): The slug (short URL) of the post category.

    • $posttype (string): The type of post (post type).

  • Usage:


chapter_url()

  • Purpose: Returns the URL for a post's chapter.

  • Parameters:

    • $slug (string): The slug (short URL) of the post category.

    • $chap (string|int): The chapter or episode number.

    • $posttype (string): The type of post (post type).

  • Usage:


table_posttype() & table_posttype_relationship()

  • Purpose: Returns the database table name for the given posttype.

  • Parameters:

    $posttype (string) : The type of post (e.g., "blog", "movie", "product").

  • Usage:


iframe_url()

  • Purpose: Returns the URL for viewing content via an iframe.

  • Parameters:

    • $slug (string): The slug (short URL) of the post category.

    • $posttype (string): The type of post (post type).

  • Usage:


user_url()

  • Purpose: Returns the URL for a user's page.

  • Parameters:

    • $slug (string): The unique identifier or username of the user

  • Usage:


convert_to_string_number()

  • Purpose: Converts numbers to a compact format (K, M, B).

  • Parameters:

    • $num (int|float): The number to be formatted.

  • Usage:


api_upload_url()

  • Purpose: Returns the API URL for file uploads.

  • Parameters:

    • $act (string): The action to be performed (e.g., "image_upload", "video_upload").

    • $params (array): Additional parameters to be added to the API request.

  • Usage:

circle-check

Last updated

Was this helpful?