• Resolved julianat

    (@julianat)


    Hello everyone,

    I’m currently working on a download portal for free files, and my goal is to have a link open a form created with ‘Contact Form 7’ (which is already functioning) that includes the title of the download, so I can identify which download the request is for. Generally, this is not a big deal and works when I open a single download page on my website. However, it doesn’t work when I list the downloads on a page using a shortcode like ‘[sdm_show_dl_from_category category_slug=”2143″ fancy=”1″ pagination=”20″]’, as it only displays the title of the page itself—in my case ‘test’—and not the specific download title, such as ‘2143 – Alle Bilder’.

    I’m currently using the shortcode [dynamictext dynamicname “CF7_get_current_var key=’title'”], but this only displays the title of the page, not the title of the download in a download category overview.

    To keep things simple, I’m looking for a solution to grab the download ID and the download TITLE. Alternatively, I need to know how I can modify the existing template without losing my changes after a plugin update.

    You can see an example on the given page. Click on “Kontaktformular ?ffnen” and you’ll see the title of the page above the checkbox.

    Displaying “test”: https://www.merker.sh/test/
    Displaying “2143 – Alle Bilder”: https://www.merker.sh/sdm_downloads/2143-alle-bilder/

    I already tried creating a child theme and copying the template files from your plugin into my child theme to make my changes ‘update-safe’, but it seems this is not currently supported by your plugin.

    Best regards,
    Julian

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor mbrsolution

    (@mbrsolution)

    Thank you for reaching out to us.

    I’m currently working on a download portal for free files, and my goal is to have a link open a form created with ‘Contact Form 7’ (which is already functioning) that includes the title of the download

    We currently don’t have an integration with Contact Form 7 plugin unfortunately.

    Here are a couple of documentations that might help you.

    A list of filter hooks.

    https://simple-download-monitor.com/simple-download-monitor-filter-hook-reference/

    A list of PHP tweaks.

    https://simple-download-monitor.com/download-monitor-plugin-miscellaneous-php-tweaks/

    Kind regards.

    Thread Starter julianat

    (@julianat)

    Hey mbrsolution,

    thank you for your response. I achieved my goal with the following modification in the functions.php file:

    add_filter('sdm_generate_fancy1_display_output_html', 'customize_sdm_fancy1_output', 10, 2);

    function customize_sdm_fancy1_output($output, $args) {
    // Get the download title based on the download ID
    $download_title = get_the_title($args['id']);

    // Removing HTML entities from the title
    $download_title_plain = html_entity_decode($download_title, ENT_QUOTES, 'UTF-8');

    // Generate a unique ID for the form and input field
    $unique_id = 'download-' . $args['id'];

    // Create an HTML form with a button that passes the download title
    $additional_button = '<form action="#" method="post" style="display:inline;">
    <input type="hidden" id="' . esc_attr($unique_id) . '" name="download-title" value="' . esc_attr($download_title_plain) . '">
    <button type="button" class="custom-button wow-modal-id-1" style="margin-left: 10px; padding: 10px; background-color: #0073aa; color: white; text-decoration: none; border-radius: 5px;" onclick="setTextFieldValue(\'' . esc_attr($unique_id) . '\')">Fragen?</button>
    </form>
    <script>
    function setTextFieldValue(id) {
    var downloadTitle = document.getElementById(id).value;
    document.querySelector(\'input[name="text-field-name"]\').value = downloadTitle;
    }
    </script>';

    // Placing the form after the existing download button
    $output = str_replace('</span></div>', '</span>' . $additional_button . '</div>', $output);

    return $output;
    }

    To integrate it with Contact Form 7, you can use the following shortcode:

    [text text-field-name]

    In my setup, I’m also using the ‘Modal Window’ plugin to open a pop-up window that contains my contact form. This might be helpful for others as well.

    I used the following shortcode from Simple Download Monitor, along with my modifications, to display the downloads:

    [sdm_show_dl_from_category category_slug="MySuperCategory" fancy="1"]

    BR, Julian

    • This reply was modified 3 months ago by julianat.
    • This reply was modified 3 months ago by julianat.
    Plugin Contributor mbrsolution

    (@mbrsolution)

    Thank you for sharing your solution. I am sure this will help others trying to achieve the same solution as you.

    Kind regards.

    Thread Starter julianat

    (@julianat)

    Which filter should I use to change the display of a single download file?

    Like this example:
    https://www.merker.sh/sdm_downloads/1116-oebb-pflatsch/

    Best regards,
    Julian

    Thread Starter julianat

    (@julianat)

    I was able to change the output below the description using the following filter:

    sdm_cpt_below_download_description

    However, this is not exactly what I want. I am aiming for the same appearance as in my category overview.

    Desired Appearance: https://www.merker.sh/lokbilder/oesterreich/elektrolokomotiven/rh-1×16/rh-1016/
    Current Appearance: https://www.merker.sh/sdm_downloads/1116-oebb-pflatsch/

    Please note that the button on the single download page does work, but it is currently placed differently than I want it, as I would like it to be on the right side of the download button.

    Best regards,
    Julian

    Plugin Contributor mbrsolution

    (@mbrsolution)

    Unfortunately this is beyond the scope of free support. If you would like more help with development, please use the following contact form.

    https://simple-download-monitor.com/contact-us/

    Kind regards.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.