joer80
Members-
Posts
364 -
Joined
-
Last visited
Everything posted by joer80
-
Very handy! Thanks for taking your time to look into all of this. I havn't even had the chance to add the checkbox logic and you have all of the sample code. I will use that timer code to start timing things on future snippets.
-
That is a handy addition! I would be curious if I did it this way, if it would still have the delay or not? Does it still pull all 2k pages and populate it into the $item var and this just doesn't loop through it anymore? I used to be about 3-5 seconds extra on all page loads but I can test it. But like you said, caching helps for most of the time..
-
Nice.. Can I tell it to only go 2 levels since that is all bootstrap supports?
-
This is what I am using right now to make bootstrap menus with active link colors and drop downs before I add the above new window redirect code: <?php $LogoImage = 'logo.png'; $NavColor = 'navbar-default'; //navbar-default or navbar-inverse //Make the menu //echo the starting code echo '<nav class="navbar ' . $NavColor . ' navbar-fixed-top" role="navigation"> <div class="container"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="' . $config->urls->root . '"><img src="' . $config->urls->templates . 'images/' . $LogoImage . '" class="Logo" alt="' . $LocationPage->title . ' Logo" /></a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="navbar-collapse-1">'; echo '<div id="AboveNav"><i class="fa fa-phone"></i> ' . $LocationPage->Location_PhoneNumber_Switchboard . ' <i class="fa fa-flag"></i> ' . $LocationPage->Location_AddressStreet . ' ' . $LocationPage->Location_City . ', ' . $LocationPage->Location_StateAbrv . '</div><!-- -->'; echo '<ul class="nav navbar-nav navbar-right">'; //Make the top level links $TopLevelNavLinks = $pages->find('parent=1, sort=sort'); //add home link echo '<li><a href="/">Home</a></li>'; //could use $config->urls->root //Build Top Level Links foreach($TopLevelNavLinks as $TopLevelNavLink){ //Look up this top level link to build a drop down if it needs it $SecondLevelNavLinks = $pages->find("parent=$TopLevelNavLink->id, sort=sort"); $SecondLevelTotal = $SecondLevelNavLinks->getTotal(); //If I am on this page, add the active class if($page->id == $TopLevelNavLink->id){ $classTag = ' active'; } else { $classTag = ''; } //if there is atleast one sublink, put me in a dropdown if($SecondLevelTotal > 0){ //Dont make link take user to page. Instead, open a dropdown menu. echo '<li class="dropdown' . $classTag . '">'; echo '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">' . $TopLevelNavLink->title . ' <span class="caret"></span></a>'; echo '<ul class="dropdown-menu" role="menu">'; //loop through the second level foreach($SecondLevelNavLinks as $SecondLevelNavLink){ //If I am on this page, add the active class if($page->id == $SecondLevelNavLink->id){ $classTag2ndlevel = ' class="active" '; } else { $classTag2ndlevel = ''; } echo '<li' . $classTag2ndlevel . '><a href="' . $SecondLevelNavLink->url . '">' . $SecondLevelNavLink->title . '</a></li>'; } echo '</ul>'; } else { //Make link take user to page echo '<li class="nodropdown' . $classTag . '"><a href="' . $TopLevelNavLink->url . '">' . $TopLevelNavLink->title . '</a></li>'; } } //end of built top level nav links //echo the ending code echo '</ul></div><!-- /.navbar-collapse --> </div><!-- /.container-fluid --> </nav>'; ?>
-
The reason why I do not do the $item->children method, is if someone has a database of products under a page tied to the navigation, it makes it a lot slower and uses more memory. Especially if there are thousands of products. ie. A layout using Home -> Inventory -> All Inventory -> Item1 would not be good. I noticed a huge speed boost when I went to 2 queries. (Bootstrap only supports 2 levels, so no need to go deeper.)
-
Got you! Not sure why I was thinking all pages would need new window functionality. I am really only concerned with websites that link off my url. That should work! Thanks!
-
Yeah, I will have to add it to all of my templates that can be in the nav though I think, as well as a url box to all templates. In the past, I just had one template that was a redirect template. I think this is my best option though... Just not as neat and clean.
-
Custom code that uses the bootstrap format. One query finds top level links by getting the children of the homepage $TopLevelNavLinks = $pages->find('parent=1, sort=sort'); And then I do a second query to loop through each of those $SecondLevelNavLinks = $pages->find("parent=$TopLevelNavLink->id, sort=sort");
-
It sounds like adding the javascript to pop open a new window to this template wouldnt work, because you will still have this page open also, which would be blank. Sounds like I just need to do it with a blank target before I get to this page/template?
-
I have a template called redirectPage.php and it only has one line of code. $session->redirect($page->redirectTo_URL); How would I go about telling this to open the link in a new window instead of the current one? (In my navigation if I want to link to a different address than itself, I set the page to this template and paste in the url into the redirectTo_URL field. I also want to add a checkbox for if it is a new window or not. To get my top level nav links, I search for this: $pages->find('parent=1, sort=sort') Thanks!
-
New Template Method: Does this make sense to do it this way?
joer80 replied to joer80's topic in API & Templates
Did you use the alternate template filename method to pick a column number? I am trying to figure out the best way to make it user friendly. -
New Template Method: Does this make sense to do it this way?
joer80 replied to joer80's topic in API & Templates
The css and js is not stiched on page load of a regular template. It is a page that doesnt run much in the admin section side. Or you could call it when a template is edited in admin. No need to stitch for a user view. The purpose is not for the clients to design the website, but a graphics person that can not program that would help launch websites for clients. It sounds complicated because we are talking the under the hood inner workings. It wouldnt be bad to use. Most things are complicated when you look at the code. -
New Template Method: Does this make sense to do it this way?
joer80 replied to joer80's topic in API & Templates
Well i would prepare the rows in advance before i knew anything about the project using the css and html and they would just put it together and choose images to make the website. That may be different than what you experienced. -
Let me know if you think this will work, and would be a good idea of a way to layout my website and templates. The idea/end goal is you could download the this profile and build a website without touching a line of code. php or css. To build the website, you would just create templates in the backend that do not use their own template file, but use the alternate template file setting of main100.php, main50-50.php or main75-25.php depending on what you want to create. (That tells the system how many rows you want to use and what size they are.) The profile would also come with extra fields you can use. (Mostly repeaters.) Next, you would add those fields and repeaters to template files you create. (Each repeater would be a row on your website, and you can drag and drop the row order by editing your templates.) The main template files the website comes with run a "makerows" function in them in certain areas. ie. main100.php runs makerows('header') and makerows('content'), while main75-25.php runs those and also makerows('sidebar'). They also run a makeJS function at the bottom of the page, and import a merged.css file in the head area. The profile would also have a folder that organizes the row code snippets based on where they are suppose to print, and that variable I am passing in the makeRows function would be the location of that snippet. Default options are: content, sidebar, header, footer. The example folder structure for the content snippets is: bootstrap/ bootstrap/content bootstrap/sidebar bootstrap/header bootstrap/footer bootstrap/header/pageTitle bootstrap/header/sliderRow bootstrap/header/ParalaxRow Each row folder would have 1-3 files in them, and an optional /images/ sub folder maybe? bootstrap/header/pageTitle/code.php bootstrap/header/pageTitle/style.php (Optional) bootstrap/header/pageTitle/js.php (Optional) The code.php file would have the html markup for the row and the php variables in it placed where they need to be, style.php has all css styles used in this row, and js would have any javascript this row needs. (I did style as a php file so you could use variables for the colors, but the website merges it into a .css file automatically.) I have a page in my admin backend that when ran, it will loop through each subfolder in my bootstrap folder, and read each style.php file in each folder, and build out a merged.css file in my template directory. That is why my main templates never call a css function, they just import the merged file. When the page you are on loads and calls the makerow function, it just loops through all repeaters tied to the current page you are on for that location you passed, ie. header, content, sidebar. It then checks for a snippet named that same way. ie. A sliderRow repeater on your page would look for the sliderRow folder, and include the code.php file in that folder. What do you think? Or is this not a good approach? I have it working, but I am also wondering if there was a way to assign a default alternate template filename of main100.php to each template the user adds? Or would there be a better way to have their templates that holds the repeaters separate from the main templates that just set the columns they want? Thanks!
-
Possible to grab field in first repeater group without looping?
joer80 replied to joer80's topic in API & Templates
They both work! Thanks for the tip! -
Possible to grab field in first repeater group without looping?
joer80 replied to joer80's topic in API & Templates
Great! I will give that a try! So this should work? echo $page->ThisRepeater->first()->h1; -
Possible to grab field in first repeater group without looping?
joer80 replied to joer80's topic in API & Templates
Ha, think I guessed right. This seems to work: echo $page->ThisRepeater[0]->h1; Nevermind! -
I am pretty sure I tried to loop it again and it didn't work, but I will make sure! Thanks!
-
The settings say max files = 0 (no limit), and formatted value is Automatic (single item or null when max files set to 1, array of items otherwise)
-
If I add a new text field called Caption to the repeater, it seems to work. I just can't access the image description field. this works: foreach($page->Carousel as $Slider){ if($Slider->Caption){ $Slidercaption = '<div class="carousel-caption"><h2>' . $Slider->Caption . '</h2></div>'; } else { $Slidercaption = ''; } }
-
Is it possible repeaters have a variable named description that is messing with the description field of an image in a repeater?
-
Ok, I have a repeater on my page called Carousel, and it has an image field in it called Slider_Graphic. I am trying to access the image description field and I am not having any luck. Can you tell me what I am doing wrong? This is my code: //Loop through Carousel repeater on this page foreach($page->Carousel as $Slider){ echo $Slider->Slider_Graphic->url; echo $Slider->Slider_Graphic->description; } It outputs this: /site/assets/files/29135/ for the url, but the description comes up empty. (It is set in the backend.) :\
-
Yeah, it installed it as being not the first and I did have to move it, but it still seems to only work if you use the tabs. Not sure why I am not the same as yours. I am running the default admin even.
-
Awesome! Thanks!