We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

very odd behaviour, bug?

Development and Programming

icicic's avatar
icicic
8 posts
4 years ago
icicic's avatar icicic

I’ve built a module that creates a new file from text between a tag pair, before creating the new file if a similar file already exists it moves it to an archive folder, it then writes the path for the new file back to the template.

I can send the file name back to be displayed in the template, this works fine, however as soon as I create a valid link to the new file and return or echo the new file path back to the template I have problems; the newly created file also gets copied to the archive folder, sometimes twice (the filename includes a timestamp, so sometimes it’s copied twice with a second difference).

Template tags:

{exp:custom_mod:test}
  Some data.....
 {/exp:custom_mod:test}

Module code:

public function test()
    {
        $page_data = ee()->settings_model->get_settings();

        //fetch all files from folder
        $directory = $page_data['folder_path'];
        $pattern = "custom.*txt";
        $files = ee()->file_model->folder_iterator($directory, $pattern);

        //move existing to achive folder
        ee()->file_model->move_to_archive($files);

        //create new file and get link to it
        $name = ee()->file_model->create_new_file();

        $link_text = '<link href="' . $name . '" rel="stylesheet" >';

        // this works as expected
        return;

        //this causes more than one new file to be created
        return $link_text;
    }

Have found that this only seems to happen with stylesheets, and if I remove ‘rel=”stylesheet” from the returned data the code behaves as expected.

What is happening?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.