Jump to content

joer80

Members
  • Content Count

    342
  • Joined

  • Last visited

Community Reputation

160 Excellent

About joer80

  • Rank
    Sr. Member

Contact Methods

  • Website URL
    http://www.webprojoe.com

Profile Information

  • Gender
    Male
  • Location
    Texarkana, TX

Recent Profile Visitors

3,916 profile views
  1. I have been working on a way to layout the files in my template folder that allows people to have more than one theme per website, and better organize the template files and pages, and this is what I came up with. What do you guys think? Has anyone done anything similar? File Layout: /templates/ _init.php. (includes and variables you want all pages to access. I put setting('theme', 'kick-off-news'); to define the active theme.) default.php (Template files can be told to use this for default behavior, or you can clone its contents for more control. I haven't needed to yet.) What is in the default.php file: <? namespace ProcessWire; //sitewide variables and/or functions. ie. Define setting('theme') as active theme. include('_init.php'); //The default temmplate can use the default HTML for the active theme $templateFilePath = $config->paths->templates . 'themes/' . setting('theme') . '/default.php'; //Render template file for the active theme echo $files->render($templateFilePath); ?> /temlates/themes/ (Holds all theme folders.) /temlates/themes/kick-off-news/ Here is what I am putting in the theme folder: /content/ (This has content subfolders for organization. ie. I did /by-page/ and /by-template/. (folders can be autoloaded from page path and template name.) /includes/ (Used for code that will be included across templates, like navigation.) /css/ /js/ /img/ default.php (You can clone for more control if needed, but I have not need to.) Below is an example of what could be in the /temlates/themes/kick-off-news/default.php file. <? namespace ProcessWire; ?> <!DOCTYPE html> <html lang="en"> <head> <? include('./includes/head.php'); ?> </head> <body> <? include('./includes/topAd.php'); include('./includes/header.php'); include('./includes/navigation.php'); //Use selected homepage if no page path. if($page->path == '/'){ $pagePath = setting('home'); //active homepage path. ie /pages/home/ } else { $pagePath = $page->path; } //Load content file for this page if it exists if(file_exists('./content/by-page' . $pagePath . $page->name . '.php')){ include('./content/by-page' . $pagePath . $page->name . '.php'); } else { //Load content file for this template if it exists if(file_exists('./content/by-template/' . $page->template . '/' . $page->template . '.php')){ include('./content/by-template/' . $page->template . '/' . $page->template . '.php'); } } include('./includes/footer.php'); include('./includes/mobilenav.php'); include('./includes/bottom.php'); ?> </body> </html> The reason why I like to be able to select an active homepage is to be able to make another homepage, and flip back and forth on which one is active as needed. No need to copy any paste data, or upload files to another page after it is approved. I mainly only use one or the other, as far as page or template html goes, but I guess you could use both at the same time with a few changes. The advantage to using using one at a time is you dont need to check for a template content file if there is a page content file. If you want to be able to load both, you probably need to have them set output variables, and after they are both loaded, push the results out. Maybe an array with a priority key and html value and loop through the array after they both load. Was overkill for me though. How I did site Tree to organize and separate the pages from the news articles. I also think there is an advantage to this over sticking all template files in the same folder, as you can put related supporting files in the same group. A news category page sidebar can be in the same folder as the news category template. Or related news layouts are next to their parent file.
  2. So setting it manually with axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; worked! Thanks for all the help guys!
  3. So interestingly enough, my axios post by default has all of the cookies needed for the post to be done by the admin user, but it is not seen as an ajax request, so it will not continue if I force it to be ajax with if(!$config->ajax) return; This is how I am doing it. methods: { processForm: function() { //event const self = this; //so .then can access outside this. axios.post('/post/', { pageID: this.pageID, text_heading: this.text_heading }) .then(function (response) { if(response.data == 'success'){ UIkit.notification({ message: '<span uk-icon="icon: check"></span> Changes saved.', status: 'success', /* primary, warning, danger */ pos: 'bottom-right', timeout: 2500 }); } else { UIkit.notification({ message: '<span uk-icon="icon: warning"></span> ' + response.data, status: 'danger', pos: 'bottom-right', timeout: 2500 }); } }) .catch(function (error) { console.log(error); });
  4. Why is no one suggesting Invision Community? Its the forum software we are on right now.
  5. So i was under the impression the axios post doesnt have the superuser cookie just because I did. Are you saying it would if I did?
  6. I started a proof of concept using vue to do live front end edits to processwire fields and have a question. I successfully bound the text field to the vue variable and used axios to send the post to my processwire page /post/ on save, but how do I secure this post page so others can not post edits to this /posts/ page? Thanks!
  7. If I pass in rich text content with <p> tags into $sanitizer->truncate(), it seems to strip out the p tags even if I pass in the keepFormatTags option. Can anyone else confirm? $s = $sanitizer->truncate($news_story->content, ['type' => 'sentence','maxLength' => 600,'keepFormatTags' => true]); Thanks!
  8. This was very helpful to me! Thank you!
  9. Would you consider adding an insert action to the collection panel? That way people can add children? I love this! Thank you for releasing it!
  10. I added a module for this that hooks on page save. Added an ace css text field for color coded markup and when I save, if that page has a css field, it creates the .css file on the server using a timestamp name. public function init() { $this->pages->addHookBefore('save', $this, 'updateThisPage'); $this->pages->addHookAfter('save', $this, 'makeMergeFiles'); } and something like $myfile = fopen('../assets/css/' . $newAssetFilename . '.css', "w"); fwrite($myfile, $allCSS); fclose($myfile); For some reason if I move a page it doesnt work right. Have to save it to fix, but it hasnt bothered me enough to research it. lol I usually add one to my template page, and the individual page and it finds all pages with this field and merges everything into one file. I do one for js also.
  11. Oh wow! That is really neat. I will keep that in mind. After taking the time to figure it all out, I am wondering now if in my situation it would just be better to keep the tree natural, and make a dashboard that you see by default after login, that groups the pages how I want them to be grouped. lol But this may be handy to keep in the mind in the future if I redo an existing website and dont want to do redirects and need that flexibility.
  12. Thanks @kongondo I think I have it. Ryans post helped a ton! This is not a live website yet so I am playing around with the tree layout, but I do see perks for this. This is the tree: Root - Pages - Posts - Services - Products - Menus So I wanted pages to be special in that for a page like /pages/about/, you could opt to use the short form /about/. This not only matches most websites you would migrate to processwire, but it is so clean and organized. Also, I wanted you to be able to have 2 homepages, and edit the root page and select which page you want to load as your active homepage. You could even make the blog or posts page your homepage with a click. After looking at Ryans code, I ended up turning on page segments for root and doing the below code in my root.php. //Allow pages to sit under root instead of under pages area. if($input->urlSegment(1)){ //might be 404 or a url directly under root. $realPage = $pages->get('/pages/' . $input->urlSegment(1) . '/'); if($realPage->id){ $page = $realPage; } else { throw new Wire404Exception(); } } else { //matched a page, no need to check for short link. //Set the root variable and page variable. (If on homepage, use the selected homepage instead) if($page->id == 1){ $root = $page; $page = $page->selected_homepage; } else { $root = $pages->get('/'); } } I also fixed the page path like this in site/init.php //If we are viewing the long path for a page, set the path value to the short version. (Pages live in /pages/) $wire->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'page') { $event->replace = true; $event->return = "/$page->name/"; } });
×
×
  • Create New...